Instead of talking about specific technologies/software/services, I'll give a quick rundown how you can achieve this in theory, and hopefully it can apply to whatever you're currently using.
The requirements:
- Your application should be able to run on arbitrary ports, preferably controlled with env vars or similar
- You need to have something in front of your application, like nginx or apache
- Whatever webserver you have should be able to "hang"/pause/suspend requests while you switch application version
- Each version you create needs to be concerned about what the previous version did. Breaking changes needs to happen across multiple versions, where you can soft-deprecate something, and a release after that, actually "break" it
- You need to have some sort of "healthchecking" that can tell you if the new version is OK or not
The implementation:
- You have Version 1 running of your backend on port X
- You want to deploy the new version, so you deploy it to your server but the web server in front still serves requests from Version 1
- Run healthchecks against Version 2
- Once they pass, tell web server to "pause" in-flight requests
- Switch web server configuration to use Version 2 application instead (this can be combined with the previous step, `nginx reload` would combine these for example)
- Stop Version 1 from running
- Repeat for each new version
And now you've achieved deploying a new version of your application without any failing requests.
(Sidenote: You can replace hanging/pausing requests with graceful shutdown of your webserver (meaning it waits for no pending requests) if you have a low amount of traffic)
The requirements:
- Your application should be able to run on arbitrary ports, preferably controlled with env vars or similar
- You need to have something in front of your application, like nginx or apache
- Whatever webserver you have should be able to "hang"/pause/suspend requests while you switch application version
- Each version you create needs to be concerned about what the previous version did. Breaking changes needs to happen across multiple versions, where you can soft-deprecate something, and a release after that, actually "break" it
- You need to have some sort of "healthchecking" that can tell you if the new version is OK or not
The implementation:
- You have Version 1 running of your backend on port X
- You want to deploy the new version, so you deploy it to your server but the web server in front still serves requests from Version 1
- Run healthchecks against Version 2
- Once they pass, tell web server to "pause" in-flight requests
- Switch web server configuration to use Version 2 application instead (this can be combined with the previous step, `nginx reload` would combine these for example)
- Stop Version 1 from running
- Repeat for each new version
And now you've achieved deploying a new version of your application without any failing requests.
(Sidenote: You can replace hanging/pausing requests with graceful shutdown of your webserver (meaning it waits for no pending requests) if you have a low amount of traffic)