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

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.

主站蜘蛛池模板: 石林| 平陆县| 梅河口市| 浪卡子县| 鸡东县| 榕江县| 陇川县| 遂昌县| 城市| 镇安县| 新邵县| 库车县| 福清市| 嘉荫县| 宜君县| 印江| 延川县| 辽宁省| 澜沧| 景德镇市| 鞍山市| 招远市| 洛南县| 孟连| 东海县| 禹州市| 文山县| 娄底市| 靖西县| 古丈县| 手机| 崇仁县| 乌拉特后旗| 惠水县| 莱州市| 二连浩特市| 渭源县| 休宁县| 信阳市| 马鞍山市| 乌兰察布市|