News for hackers. Stuff that matters.
Re:Best practices around creating production ready web apps ... by merb on Tuesday June 01, 2021 @05:09PM (#27361339)
how do you handle no downtime deployments? how do you backup data?

I rather would use kompose+kustomize to convert it to k8s and than use k3s with ingress-nginx with hostPath and backup local volumes with velero.

Re:Best practices around creating production ready web apps ... by nickjj on Tuesday June 01, 2021 @07:40PM (#27362874)
> how do you handle no downtime deployments?

I take the few second downtime hit on each deploy. I know, it's iNsAniTy but it's really not. A 5 second blip a few times a week is no biggie for most SAAS apps or services.

To me that's well worth the trade offs of not having to deal with a load balancer, a container orchestrator tool, dealing with database migrations that need to be compatible for 2 versions of your app as it's being rolling restart and all of the other fun complexities of running a zero down time service.

You can still architect your app in a flexible way (env vars, keeping your web servers stateless, uploading user content to S3 or another object store, etc.) so that moving to something like Kubernetes is less painful if / when the time comes. It's just for me, that time has never come.

> how do you backup data?

A background job / cron job runs every few hours and does a pg_dump to a directory in a block storage device. Could easily change that to be S3 too. Just comes down to preference. Personally I found it easier to drop it into block storage since it's just copying the file to a directory.

Re:Best practices around creating production ready web apps ... by goodoldneon on Tuesday June 01, 2021 @09:40PM (#27363801)
Your pragmatism is refreshing. This simple solution meets all your requirements so there isn’t a need to add complexity. Kudos!
Re:Best practices around creating production ready web apps ... by strzibny on Wednesday June 02, 2021 @11:58AM (#27370225)
I like this pragmatism and I teach it as well (https://deploymentfromscratch.com/). Just want to say that you can employ systemd socket activation for systemd services, and you can have zero-downtime deployment without load balancers.
Re:Best practices around creating production ready web apps ... by efrecon on Wednesday June 02, 2021 @02:22AM (#27365523)
Thank you for a sane comment! In many cases, downtime can even be contractually ok.
Re:Best practices around creating production ready web apps ... by mr-karan on Wednesday June 02, 2021 @10:49AM (#27369326)
This is a great response and refreshing to see things can just be simple, if one tries to cover 99% of usecases and not go crazy overboard trying to solve just 1% of edge cases with "container orchestration" :)
Re:Best practices around creating production ready web apps ... by adflux on Wednesday June 02, 2021 @02:42AM (#27365654)
Nice and simple, love it
Re:Best practices around creating production ready web apps ... by mamcx on Tuesday June 01, 2021 @05:20PM (#27361468)
You don't always need "no downtime deployments", few minutes are tolerated in many environments (I work in enterprise software, where it could be days!).

Backups? You only need backups or the Db, and that have zero impact in the use of docker or not*

*ie: I know what very complex setups the micro-service crow use for serve their smalls-size disruptive app. I still think cron + pg_dump + rsync is more than enough...

Re:Best practices around creating production ready web apps ... by merb on Tuesday June 01, 2021 @05:30PM (#27361604)
well I'm asking because I have a docker-compose file and I use kustomize+kompose on it, because volume backup is a thing and the file comes from an upstream vendor and we can actually miss a few minutes/hours/days of uptime, but since the databases also use compose and sadly in a way that I can't remove it (migrate.sh script that makes use of compose commands), else I can use my kustomize+kompose setup which basically replaces the kustomize+kompose with a custom init container that I built, however everytime they change their shell scripts I need to fix my stuff... but they say that I should just backup my whole volume/vm via lvm snapshots or via vmware whatever. which I find a little bit akward and I do not want to backup my data with disk snapshots. another way would be to natively backup stuff via compose, but they use many databases and it's way harder than just use velero.
Re:Best practices around creating production ready web apps ... by vbsteven on Tuesday June 01, 2021 @05:30PM (#27361603)
I’m not the parent but I’ll pitch in on this as I have a few client projects using docker compose for production.

No downtime deployments: I don’t bother for these projects. A minute of downtime in off-peak hours for a restart is fine.

Data backup: just like you would backup any other local data: cron, rsync, pg_dump. And there isn’t much local data anyway as most services are stateless, using S3 or a database for long term storage.

I choose docker compose for production when I want to keep complexity to a minimum: All I need is a cloud vm, an ansible playbook to install docker and configure backups. Typically in these scenarios I run the database as an OS service and only use docker for nginx/redis and application services.

Re:Best practices around creating production ready web apps ... by angrais on Tuesday June 01, 2021 @06:54PM (#27362506)
Why do you use the database as an OS service and not in docker?

Using it in docker would allow easier local development, and shorter setup time.

Re:Best practices around creating production ready web apps ... by vbsteven on Tuesday June 01, 2021 @07:20PM (#27362732)
For local development I run the full environment including the database in docker compose.

For production some of these projects run alongside each other on the same host and share the database service. Sometimes the database is on another host.

A typical host like this would be a 50/month Hetzner dedicated machine with only docker daemon and postgres installed natively. And then multiple projects deployed with docker compose. Sometimes nginx is native as well with vhosts pointing to the docker projects.

Edit: s/ghosts/vhosts/

Re:Best practices around creating production ready web apps ... by axlee on Wednesday June 02, 2021 @11:36AM (#27369914)
It is really not recommended to run (production) databases in Docker, unless you know what you are doing.

https://vsupalov.com/database-in-docker/

Re:Best practices around creating production ready web apps ... by lmeyerov on Tuesday June 01, 2021 @06:02PM (#27362009)
We've been doing this because alternatives like k8s burned out time, $, and other team members, and our on-prem customers like it operationally vs k8s. SW teams ran high uptime stuff before k8s, and you can still do most of those tricks. We're revisiting, but selectively and only b/c we're now getting into trickier scenarios like multi-az and potentially elastic GPUs for our SaaS offering

Ex:

- blue/green stateless nodes

- DNS/load balancer pointer flips

- Do the DB as a managed saas in the cloud and only ^^^ for app servers

- Backups: We've been simply syncing (rsync, pg_dump, ..) w/ basic backup testing as part of our launch flow (stressed as part of blue/green flow), and cloud services automate blob backups. We're moving to DBaaS for doing that better, which involves taking the DB out of our app for our SaaS users

In practice, our service availability has been largely degraded by external infra factors, like Azure's DNS going down, than by not using k8s/swarms for internal infra. Likewise, our own logic bugs causing QoS issues that don't show up in our 9's reports.

Re:Best practices around creating production ready web apps ... by rualca on Wednesday June 02, 2021 @02:29AM (#27365574)
> We've been doing this because alternatives like k8s burned out time, $, and other team members, and our on-prem customers like it operationally vs k8s.

It doesn't seem you bothered looking into alternatives.

Take for example docker swarm. It already uses docker compose files (well, there are some differences) , they support blue-green deployments of stacks, and they even support multi-node deployments and horizontal scaling.

Re:Best practices around creating production ready web apps ... by lmeyerov on Wednesday June 02, 2021 @05:40AM (#27366729)
Swarm was/is a bad bet due to looking like Docker gave up on it, esp. for deploying to our on-prem users where we can't just change our mind the next day, and wanting something we'd have some faith in for 2-3 years. Nomad was more appealing from the simplicity view, esp. as we'd need to do some rewriting either way.
Re:Best practices around creating production ready web apps ... by zmmmmm on Tuesday June 01, 2021 @06:07PM (#27362056)
> I rather would use ...

you'd rather use six complex things instead of one simple one?

Re:Best practices around creating production ready web apps ... by merb on Tuesday June 01, 2021 @06:56PM (#27362526)
well I asked, because everybody answered either with the following:

> we do not care about no downtime or stateless nodes and a lb in front

and b:

> backup with the standard tooling or stateless nodes

so basically they just use it mostly to "package" the application and everything else is probably done with different tooling.

Re:Best practices around creating production ready web apps ... by rualca on Wednesday June 02, 2021 @02:31AM (#27365588)
> you'd rather use six complex things instead of one simple one?

By that measuring stick, using Docker Swarm instead of docker compose is even simpler as you only need to use docker alone instead of having to install a separate script.

Re:Best practices around creating production ready web apps ... by octopoc on Wednesday June 02, 2021 @07:04AM (#27367239)
docker-compose is now built into the docker command line. e.g., `docker compose` instead of `docker-compose`
Re:Best practices around creating production ready web apps ... by mhuffman on Tuesday June 01, 2021 @06:55PM (#27362519)
Another one here! I use docker-compose, normal periodic DB backups to S3 and a twilio script that can use a lambda function to reload the entire system or parts of it by simple phone commands when necessary. Site does millions of views per day.
Re:Best practices around creating production ready web apps ... by mixmastamyk on Tuesday June 01, 2021 @11:01PM (#27364302)
Nice. Reminds me fondly of many years ago when I sent commands via pager to long-running jobs running at work from the comfort of a nearby stool at the pub. Was eating dinner of course. ;-)
Re:Best practices around creating production ready web apps ... by bcoughlan on Wednesday June 02, 2021 @05:43AM (#27366741)
I've done zero-downtime deployments with the same Docker compose file running on multiple nodes. I just had a Python script (~100 lines) that would take instances off the load balancer in turn, update the docker-compose file, add them back, wait for a warm-up period and move on to the next ones.
Re:Best practices around creating production ready web apps ... by xorcist on Wednesday June 02, 2021 @03:57AM (#27366113)
How do you do any deployments?

It's common to have a load balancer, that routes traffic to nodes that are up.

That part is mostly straightforward. It could be the application's responsibility or the load balancer's. The tricky bit is maintenance on the load balancing parts.

Re:Best practices around creating production ready web apps ... by mahalol on Wednesday June 02, 2021 @03:44AM (#27366032)
I know this wasn't intended as satire, but that's how I read it.

Very modern stack but totally overengineered.

Re:Best practices around creating production ready web apps ... by aprdm on Tuesday June 01, 2021 @06:16PM (#27362158)
How's it different than running things with pure docker or before docker? There were backups and no downtime deployments before docker became a thing... docker compose is already a layer above docker (but really just docker).
Re:Best practices around creating production ready web apps ... by merb on Tuesday June 01, 2021 @06:57PM (#27362537)
yeah but stuff like that is hard and not solved with compose, you can update your compose but that would result in downtime, so you can either do a/b (blue/green) deploys or you somehow reload the content inside the container?! everything that needs special tooling.
Re:Best practices around creating production ready web apps ... by aprdm on Tuesday June 01, 2021 @08:18PM (#27363238)
You can have a compose with multiple backend services and an nginx load balancer in it proxing back to it each one, then down/up each each backend service individually when upgrades for example..
Re:Best practices around creating production ready web apps ... by ta988 on Tuesday June 01, 2021 @09:44PM (#27363831)
Which may force you to handle two versions of databases schemes instead of a single migration. This adds complexity and sometimes 1min of down time is more acceptable than that additional work.
Re:Best practices around creating production ready web apps ... by aprdm on Tuesday June 01, 2021 @11:15PM (#27364406)
Yeah for sure, but I feel that's a software design problem and not directly related to using docker compose or not, you could have this same issue regardless of how you go about deploying it.
Re:Best practices around creating production ready web apps ... by rualca on Wednesday June 02, 2021 @02:35AM (#27365607)
> You can have a compose with multiple backend services and an nginx load balancer in it proxing back to it each one, then down/up each each backend service individually when upgrades for example..

Things are way simpler with Docker Swarm. You just run a single ingress controller as a separate stack and route all traffic internally.

If you use Traefik as your ingress controller, all you need to do is set labels in your docker compose files and everything just works.

There is absolutely no reason or excuse to use docker compose in anything resembling production.

Re:Best practices around creating production ready web apps ... by simongray on Wednesday June 02, 2021 @04:12AM (#27366199)
> There is absolutely no reason or excuse to use docker compose in anything resembling production.

I work at a university where I make an app meant for maybe a couple of concurrent researchers. Am I seriously supposed to set up Docker Swarm for this or is it OK with you if I run my little setup using Docker-compose on the tiny server that the university has provisioned for me?

Seriously, why do so many people on HN have to act like the entire world of software developers is busy making the next Facebook? I'm sure many (most?) people are making tiny things meant for tiny audiences.

Re:Best practices around creating production ready web apps ... by croon on Wednesday June 02, 2021 @04:32AM (#27366319)
> Seriously, why do so many people on HN have to act like the entire world of software developers is busy making the next Facebook? I'm sure many (most?) people are making tiny things meant for tiny audiences.

I agree generally, but playing devil's advocate for GP, what I think they meant is that swarm can be run on a single node with little downside/complexity and a lot of upside from docker compose.

See for example:

https://jarredkenny.com/single-node-docker-swarm/

https://devopstuto-docker.readthedocs.io/en/latest/docker_sw...

Re:Best practices around creating production ready web apps ... by simongray on Wednesday June 02, 2021 @05:17AM (#27366583)
Thanks for the links. I was not aware that it could be run on a single node. Still, the benefits are unclear to me. I guess I will research it some more.
Re:Best practices around creating production ready web apps ... by rualca on Wednesday June 02, 2021 @07:25AM (#27367379)
> Still, the benefits are unclear to me.

Manage deployments as stacks, which support history and backtrack deployments.

Blue-green deployments.

Frankly, it boggles the mind how people put to production devtools that are barely managed to be secure when deployed locally, when alternatives are both simpler to deploy and more capable.

Re:Best practices around creating production ready web apps ... by simongray on Wednesday June 02, 2021 @11:46AM (#27370044)
I am in charge of every single thing from devops to data modelling to backend web services to frontend apps to design and testing to responding to inquiries from users of a dozen web services. Does that boggle your mind too? That is the reality of my job. I don't have the time to be an expert in every single area when I am the one who has to do everything.

I'm sure you're great at setting up servers. That is probably the part of my job I dislike the most, but it's something I have to do, so I do it.

Re:Best practices around creating production ready web apps ... by croon on Wednesday June 02, 2021 @08:16AM (#27367767)
The charitable assumption is that people use the (best) tools they're aware of. Discovery can be really hard today.
Re:Best practices around creating production ready web apps ... by KurtMueller on Wednesday June 02, 2021 @08:34AM (#27367937)
Docker has documentation on how to deploy compose apps to services like Azure Container Instances or Elastic Container Services. It's specifically for using compose in production.

https://docs.docker.com/cloud/aci-compose-features/ https://docs.docker.com/cloud/ecs-compose-features/

Re:Best practices around creating production ready web apps ... by aprdm on Wednesday June 02, 2021 @10:55AM (#27369413)
That looks much more complicated than scp a yaml file and run a single command. Which is all you need for a lot of real production apps.