Zero downtime deployment for Java apps

前端 未结 5 1317
礼貌的吻别
礼貌的吻别 2021-02-04 08:09

I am trying to build the very lightweight solution for zero downtime deployment for Java apps. For the sake of simplicity lets think that we have two servers. My solution is to

5条回答
  •  有刺的猬
    2021-02-04 08:40

    I have found some interesting solutions from this article regarding Zero downtime. I would like to highlight only few solutions in that article.

    1. A/B switch: ( Rolling upgrade + Fallback mechanism )

    We should have a set of nodes in standing by mode. We will deploy the new version to those nodes and switch the traffic to them instantly. If we keep the old nodes in their original state, we could do instant rollback as well. A load balancer fronts the application and is responsible for this switch upon request.

    cons: If you need X servers to run your application, yon need 2X servers with this approach.

    2. Zero downtime

    With this approach, we don’t keep a set of machines; rather, we delay the port binding. Shared resource acquisition is delayed until the application starts up. The ports are switched after the application starts, and the old version is also kept running (without an access point) to roll back instantly if needed.

    3. Parallel deployment – Apache Tomcat: ( For web applications only)

    Apache Tomcat has added the parallel deployment feature to their version 7 release. They let two versions of the application run at the same time and take the latest version as default.

    4. Delayed port binding:

    we propose here is the ability to start the server without binding the port and essentially without starting the connector. Later, a separate command will start and bind the connector. Version 2 of the software can be deployed while version 1 is running and already bound. When version 2 is started later, we can unbind version 1 and bind version 2. With this approach, the node is effectively offline only for a few seconds.

    5. Advanced port binding:

    By breaking the myth: ‘Address already in use’, *both old process & new process will bind to same port. SO_REUSEPORT option in ON mode lets two (or more) processes bind to the same port. Once the new process binds to the port, kill the old process.

    The SO_REUSEPORT option address two issues:

    1. The small glitch between the application version switching: The node can serve traffic all the time, effectively giving us zero downtime.

    2. Improved scheduling:

    In Summary:

    By combining both late binding and port reuse, we can effectively achieve zero downtime. And if we keep the standby process around, we will be able to do an instant rollback as well.

提交回复
热议问题