1

I have limited resources so I can't set complete microservices architecture with docker & kubernetes, and my app is being used continuously bu users.

I have to re-deploy my app for each new release/hot-fix, do you know how can I achieve that with minimal down time?

Information about my app:

  • Startup duration in the server: 80 seconds.
  • Port: 8080
  • App server: embedded tomcat
  • Spring-boot release: 2.0.1.RELEASE.
  • I am behind a corporate nginx reverse proxy.
  • Packaging: jar
  • Stage: production

I thought about this solution:

  • Setting up internal nginx that listens on port 8080 rather than my app and forward to new port.
  • Each time I want to deploy, I start my app in a new different port and change nginx conf then reload it.

Is there anyone who faced this problem before ? or any thought how to achieve it?

Thank you in advance.

Incepter
  • 2,711
  • 15
  • 33
  • For normal Tomcat setup you can deploy multiple vorsion of the app on the same context path. New users will see the new version of your app. But don't know how this would work in embedded Tomcat case: https://tomcat.apache.org/tomcat-9.0-doc/config/context.html#Naming – Selaron Nov 29 '18 at 09:35
  • @Selaron thank you for your answer, indeed i have embedded tomcat with springboot and I am facing this problematic. to switch to tomcat i have to mesure impact and copy all my configurations and also change my app design (exclude tomcat and packagin and..) – Incepter Nov 29 '18 at 09:39
  • 1
    Ask the person who runs the corporate nginx proxy to load balance between two instances of your application, e.g. one running on `8080` and one on `8081`. You can then update your applications one at a time. You might also need to externalise certain things, e.g. running any session management on a separate host, instead of relying on the in-memory session handling. – Heuriskos Nov 29 '18 at 13:27
  • @AlexB +1 I appreciate the idea since there is a health check in nginx. Thanks – Incepter Nov 29 '18 at 14:20
  • Added as a possible answer – Heuriskos Nov 29 '18 at 14:28
  • Can you define "downtime"? Sounds silly, but reasonable people can disagree over whether responding to an HTTP client with "503 Unavailable" counts as "downtime" or if you have to be refusing connections. Others may say that the service is "down" if a request doesn't return within a certain period of time, even if it's "running" perfectly well. – Christopher Schultz Nov 30 '18 at 20:55

1 Answers1

4

Ask the person who runs the corporate nginx proxy to load balance between two instances of your application, e.g. one running on 8080 and one on 8081. You can then update your applications one at a time. You might also need to externalise certain things, e.g. running any session management on a separate host, instead of relying on the in-memory session handling.

upstream production {
    server 123.456.789:8080;
    server 123.456.789:8081;
}

server {
    listen 80;
    server_name some.host;
    location / {
        proxy_pass http://production;
    }
}

https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/

You'll need to be able to dynamically configure Spring Boot's server port to make the application listen on separate ports. Alternatively, you could also make them run on separate hosts.

Heuriskos
  • 472
  • 3
  • 6