Dockerizing Mongo and Express
Now that we are familiar with the Docker and how it helps us in high isolation and compartmentalization; lets expand and try out deploying some real world application. I will be using the application that we built for MongoDB and Mongoose; its an Express JS / MongoDB application and we will try deploying it across two Docker containers; one for MongoDB and the other for Express in spirit of Microservice Architecture. As per wikipedia; Microservices are a more concrete and modern interpretation of service-oriented architectures (SOA) used to build distributed software systems. Like in SOA, services in a microservice architecture are processes that communicate with each other over the network in order to fulfill a goal. Also, like in SOA, these services use technology agnostic protocols. Using separate Container for each microservice; we get fine control and can monitor and distribute components of our application at each microservice level.
.NET 4 - CountdownEvent
A while ago I was asked to complete a job that polls a data from many devices connected over satellite (slow and congested) links. The requirement was to poll data periodically; and somtimes while previous poll cycle was running the next poll time gets triggered. I used the Abortable Threadpool to implement this but still had to implement my own Count Down approach so that I can track if the job gets completed in the alloted time; it simply returns else after the allowed time; it aborts all the remaining queued work! It was really ugly implementation; I had to periodically check if the completed count has reached the queued work count. Now we have a new class in .NET; CountdownEvent; which exactly does the same. Its a synchronization primitive that signals when its count is reached zero. The code now looks neat!
.NET 4 - Barrier Class
Barrier class is newly introduced in .NET 4 and it enables the multiple tasks to cooperatively work on an algorithm in parallel through multiple phases. For instance you are polling the data from multiple data source; and this polling is multi step process. While polling in parallel you want coordination that on each step the parallel running tasks before moving to next step coordinate with each other. Visual Studio 2010 and .NET Framework 4 Training Kit (October Preview) has a great sample which I am reproducing below!