- Java EE 8 and Angular
- Prashant Padmanabhan
- 445字
- 2021-07-02 19:22:39
Scale only what needs to scale
The ability to scale a particular application service is one of the greatest benefits of using this architectural style. A business's ability to meet its growing demands depends on the ability of its application to scale as needed. While breaking the application into microservices gives us flexibility in scaling inpidual services, it also adds the complexity of knowing which service to scale. You can pick microservices that deal with critical business aspects, such as an eCommerce checkout service, and equip them with more hardware resources.
When packaging a microservice, you can bundle it as an executable JAR file. Solutions such as Spring Boot, Wildfly Swarm, and Dropwizard support this. With these approaches, you can bundle your application along with a server which starts as part of your application. You can also use Payara Micro, which provides a cleaner solution by separating the infrastructure (server) and your code. You can start a Payara Micro instance using java -jar payara-micro-xxx.jar and specify the WAR file that needs to be deployed on start by using a command line argument. All these options result in a single runtime process, hosting your microservice application.
In simple terms, scaling a microservice means you need to deploy more than one instance of it. With a container based solution, you can replicate the container instance using an image of your service and spawn a new instance with it. An API Gateway can act as the front for your services and a load balancer would then route the requests to a cluster of microservice instances:

A practice often seen in enterprises is using a single machine to host multiple services (think multiple JBoss/Payara instances on a single box). The problem with this is that if even one of those processes goes haywire, it will end up taking all the services running on that machine down with it. Docker containers, on the other hand, allow you to isolate each running process, thereby mitigating the risk of one rogue service killing the others. In microservices, you would want to take advantage of a container environment, to protect you from such failures.
There are more advanced techniques to scaling, such as a three dimension scalability model, as described in the book, The Art of Scalability. Once you have containerized an application using Docker and produced a Docker image, you can use Kubernetes to manage the scaling needs of your microservice applications. Kubernetes is an open source platform that helps with deploying and scaling containerized applications. The project was originally developed by Google for their internal applications. The application Google used was called Borg, which can be considered a predecessor to Kubernetes.
- INSTANT Mock Testing with PowerMock
- Boost.Asio C++ Network Programming(Second Edition)
- React Native Cookbook
- Learning Flask Framework
- Hands-On JavaScript High Performance
- Python數據分析(第2版)
- JavaScript從入門到精通(第3版)
- The Data Visualization Workshop
- Learning AndEngine
- C語言課程設計
- Hands-On Kubernetes on Windows
- 零基礎看圖學ScratchJr:少兒趣味編程(全彩大字版)
- PHP 8從入門到精通(視頻教學版)
- iOS開發項目化入門教程
- Java程序設計及應用開發