Cloud changed how we deliver services by giving application administrators access to scalable compute and storage...
resources. But cloud computing is also heavily influencing another area of IT -- application development. Organizations should reconsider application design principles and adjust patterns to take advantage of the cloud's scalability – and one way to do that is through microservices architectures.
Microservices introduce a new application design strategy that uses multiple services to implement an application, rather than build a monolithic application. For example, an organization would traditionally build an e-commerce site using a web server running user interface code, a monolithic application running all business logic and services, and a single database for all persistent storage requirements. The web and application server could each be deployed with a load balancer and autoscaling features to scale up and down according to variations in load.
Although this is a common design pattern, it has disadvantages. For instance, even small changes in a monolithic application require developers to rebuild and redeploy the entire application. This can be time consuming, and can lead to problems if developers don't thoroughly test the application. Issues can also occur when applications must maintain complicated sets of state information and it is difficult, if not impractical, to test all possible state combinations.
Another drawback of traditional application design is that it relies on a single persistent data store, typically a relational database, such as MySQL or PostgreSQL. These are popular choices because they work well in many cases, but they are not always the best option. NoSQL databases, for example, are used when flexible schemas and scalability are required. In addition, a relational database would be an ideal choice for a data storage system that needed to support transactions, such as a check-out service for a website.
Microservices architectures decompose application components into a finer-grained level than those used in monolithic applications. Instead of implementing a single application with all business logic, a developer could create one service for each logical function within the application. So, in the e-commerce example above, there could be separate microservices to retrieve product data from the catalog, another to check product inventory and another to submit a shipping order to a third-party service. Each of these services would run their own process, and applications will call these services and pass information between them as needed.
Employing microservices architectures for cloud
Microservices offer several advantages for cloud deployments.
Organizations want to run their cloud servers as efficiently as possible. In microservices architectures, they can run applications on small servers or combine multiple microservices onto a larger server to use compute resources in a more cost-efficient manner.
Also, since microservices are fine-grained, organizations only need to scale up servers that are running microservices in high demand. For example, if there is a spike in demand to run searches on a website, the autoscaling service can detect this and deploy additional servers to the search cluster. A monolithic design can run in an autoscale environment, too, but not as efficiently. The smallest instance size that a microservice needs is likely much smaller than the smallest instance that could support a monolithic application.
When using microservices in a cloud environment, always plan for security. Otherwise, illegitimate sources, or unauthorized users, could deploy these services. Microservices should require some form of authentication token that allows the service to verify the identity of the caller, as well as user authorization. Also, run fuzz tests and other types of penetration testing on your services to help identify vulnerabilities.
Microservices architectures work well with continuous deployment practices. Automation tools can help streamline the process of building code and deploying microservices to production. Again, this is true of monolithic systems, as well, but the process would not be as efficient. For example, if you had to rollback code that was already deployed, it would be less disruptive to rollback a microservices rather than a large-scale application.
Overall, microservices can complement cloud computing and allow for more efficient use of resources, especially when different services have different performance profiles.
Weighing microservices pros and cons
How to prepare your IT infrastructure for microservices
Using microservices and containers for a DevOps environment
VMware forges own microservices architecture
Learn how to make the best use of containers in microservices