官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 南昌县| 南安市| 那坡县| 金川县| 怀远县| 溆浦县| 腾冲县| 阿尔山市| 延安市| 高尔夫| 栖霞市| 抚顺县| 泰来县| 抚顺县| 达拉特旗| 河源市| 从化市| 宿迁市| 交口县| 三江| 剑阁县| 泸西县| 西乌珠穆沁旗| 平顶山市| 宁安市| 潞城市| 哈尔滨市| 丰镇市| 独山县| 梁山县| 敖汉旗| 腾冲县| 凌源市| 阳朔县| 石柱| 莒南县| 河北区| 定南县| 库车县| 准格尔旗| 仁寿县|