Best practices for deploying Java webapps with minimal downtime?

前端 未结 18 1824
我在风中等你
我在风中等你 2021-01-29 18:28

When deploying a large Java webapp (>100 MB .war) I\'m currently use the following deployment process:

  • The application .war file is expanded locally on the develop
18条回答
  •  时光说笑
    2021-01-29 18:53

    If static files are a big part of your big WAR (100Mo is pretty big), then putting them outside the WAR and deploying them on a web server (e.g. Apache) in front of your application server might speed up things. On top of that, Apache usually does a better job at serving static files than a servlet engine does (even if most of them made significant progress in that area).

    So, instead of producing a big fat WAR, put it on diet and produce:

    • a big fat ZIP with static files for Apache
    • a less fat WAR for the servlet engine.

    Optionally, go further in the process of making the WAR thinner: if possible, deploy Grails and other JARs that don't change frequently (which is likely the case of most of them) at the application server level.

    If you succeed in producing a lighter WAR, I wouldn't bother of rsyncing directories rather than archives.

    Strengths of this approach:

    1. The static files can be hot "deployed" on Apache (e.g. use a symbolic link pointing on the current directory, unzip the new files, update the symlink and voilà).
    2. The WAR will be thinner and it will take less time to deploy it.

    Weakness of this approach:

    1. There is one more server (the web server) so this add (a bit) more complexity.
    2. You'll need to change the build scripts (not a big deal IMO).
    3. You'll need to change the rsync logic.

提交回复
热议问题