Microservices vs service oriented architecture (SOA) and how containers change the rules of the game

Microservices approach gains recently popularity. Some time ago service oriented architecture (SOA) approach was very popular. But what is the difference?

Both approaches use definition of a service. I think, the main difference is the design of the service. In SOA we develop application as a monolith and provide services to access the functionality of the application. Using microservices we develop small pieces of application and combine them using services. But this is not the main thing. The most important, is again, scalability. Containers, like dockers, change the rules of the game. We can instantiate so many dockers with the same functionality (or services) as we want. This allows us unlimited scale up our application. But we need to follow small set of the rules:

Service should be stateless. That means service get data form outside, process this data internally, and send processed data further. No state is saved in meantime. If we pack this service as docker, we can create as many replicas as we need. Using microservices we can scale up and scale down the processing power of our application.

Service call can be executed many times. That means if our service update database we should prevent the repeated update. For example, our service adds 4 Euro to balance. We can add these 4 Euros only once. To achieve this we should provide to service transaction id, and during execution of the service we should check if this transaction is already executed.

Backward and forward compatibility for input parameters in service call. Our services should also work if we change format of the input data. So we need to think always about format changes. For example, if we need addtional column to object, which we send to service, service should simply ignore it.

We should keep these rules in mind by designing microservices.