26 ms·
Deployment and infrastructure for a bootstrapped webapp with 150k monthly visits
- znpy 4y agoIt’s so simple, I love it.
- criley2 4y agoIt's a lot more work than say Next.js and Vercel, but I suppose it costs a lot less to maintain in cash (trading cash for time).
- iLoveOncall 4y agoIt does not look like a lot of work at all? A few days of initial setup and that's it.
- criley2 4y agoI can go from a blank folder to deploying a git hosted next.js app on vercel in about 5 minutes, so comparatively, it is to me.
- matsemann 4y agoQuite weird to compare infrastructure of a static frontend to a backend with db and stuff?
- reducesuffering 4y agoQuite weird to rebuke the assessment with an objectively wrong statement. Next.js isn't a static frontend. You can statically generate pages w/ or w/o a DB, and server side render dynamically. A DB is literally 3 clicks and a secret string away (starting for free) with Planetscale or Railway. I've setup Django + Postgres on a VPS and Next on Vercel w/ hosted DB. Next is leagues simpler and faster to spin up. Here's Django Postgres on Digital Ocean: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-22-04 https://www.digitalocean.com/community/tutorials/how-to-set-... Next on Vercel is: 1. npx create-next-app 2. Click button for DB spinup 3. Copy secret string to .env 4. git push
- cutler 4y agoComparing Digital Ocean to Vercel is apples to oranges. One is an app platform, the other isn't.
- reducesuffering 4y agoMy comment is on a thread debating the speed-to-deliver and complexity of this traditional VPS Python deployment vs. other options. For many people on Hacker News trying to deliver a product fast, that's very relevant.
- matsemann 4y agoExcept that the time it takes to set up the project is negligible compared to actually developing it. So if it takes you 5 minutes and me 5 hours to have a new project up & running, that doesn't really matter in the end.
- reducesuffering 4y agoI’ve done a 1 month MVP on each of these stacks, it’s not just the initial deployment. React is better integrated in Next, and you can get more done faster and simpler. DRF has poor async and is not an ergonomic practice in 2022, Flask requires lots else to build and maintain with weaker integration / community, and if you’re arguing why HTML templates are just as good, well, Fortune 500 and every HN startup has left it behind for good reason.
- matsemann 4y agoIn one instance you're talking about "HNers making a quick product", and the other you're talking about fortune500s. Two vastly different things with different needs. I'm also not arguing about the specific tech. It's irrelevant. If I know tech X, choosing tech Y because it's hipper or "faster to set up" helps nothing if it's slower because it's unknown to me.
- 4y ago
- criley2 4y ago>Quite weird to compare infrastructure of a static frontend to a backend with db and stuff? I suppose you don't know what you're talking about, but Next.js is a backend and frontend supporting a wide variety of data sources. I personally like using Prisma and postgres with my Next.Js deployments. I'm literally rolling out a full stack database connected react app in minutes that includes a full functional API that can be accessed by a variety of clients.
- matsemann 4y agoBut then you suddenly have complexity again. In your various comments here you're talking about ten different tools and concepts being woven together. It's only fast for you because you've done it before. Not inherently faster than OP's approach. Like, I can spin up a k8s cluster faster than I can even understand what parts of Nextjs I should use. Doesn't mean that me selecting k8s is the best choice for all problems.
- criley2 4y agoWhat are you talking about? That's not complexity, those are out of the box features that come with a single script run (create next app or create t3 app) Vercel will even launch that for you without a script, just a button click. Five minutes to launch with my preferred stack, though. And if we're really racing, Railway.app can spin up deployments AND databases in under 60 seconds. If I tried a speed run, I could get the time down. If OP can hand configure a python app running on ngnix in manually managed DO droplets in 5 minutes... good on them! The greatest devops of our era. Also -- I guarantee that a newbie developer can launch a nextjs app faster than hand rolling some DO droplet with python and other technologies. I guarantee I can have a newbie in a bootcamp with a working app on day1 (since it's literally a button click, if we want), while I doubt you could get that newbie out of a bootcamp on his stack at all.
- matsemann 4y agoWhy so hostile in your comments? It's not a competition about being the fastest. If anything, it only shows immaturity on your part. Time spent setting up a project is negligible compared to other things surrounding it. You're anyways missing my point. Nextjs isn't a silver bullet, nothing is. And that how long it takes to set up a project is a function of familiarity with the stack. Edit: thanks for deleting all your personal attacks on me. But also remember, I'm not the one claiming to know everything here (as you wrote in your now deleted post), you're the one that critiqued OP.
- rsanheim 4y agoI'm sure everyone's mileage will vary based on experience / comfort with the particular stack here... but in my experience shipping a monolith (Python, Ruby, whatever) to a VPS is vastly simpler than a comparable Next/Vercel setup, especially for a CRUD app as the OP is talking about. Dealing with the details of things like SSR vs client side, Apollo caching (cuz w/ Next you are _probably gonna go w/ GQL, and so you probably use Apollo), and monitoring/observability in the Next/Vercel world is hard. You don't have these problems with a simple monolith, and you can sprinkle in your front end magic with whatever lean JS approach you want as you need it. And to be fair Vercel has some logging and datadog integration, but it is very limited compared to what you can get and can configure as-needed with real agent based monitoring. I'm increasingly feeling like the 'benefits' of server-side rendering in all its flavors for the big JS frameworks are just a boondoggle and not worth the complexity and cost for _most_ apps, even ones where the cost of an SPA are worth it.
- criley2 4y ago- SSR vs client side: NextJs does this automatically. https://nextjs.org/docs/basic-features/pages https://nextjs.org/docs/basic-features/pages - GQL: the only case where I'd use GQL is where he would likely want to too: building native mobile apps. Otherwise, I'd use tRPC and have fullstack type safety. This is included in my 5 minute estimate because I'd use create t3 app, which has this configured out of the box https://trpc.io/ https://trpc.io/ https://github.com/t3-oss/create-t3-app https://github.com/t3-oss/create-t3-app - monitoring/observability: not quite sure what you mean, but it's only a few clicks in vercel to have a logdrain or metric drain and configure alerts and dashboards in your tool of choice. And if I wanted to roll the whole thing myself... that's what he did. Rolled it all custom by hand. The difference is I have the option of not reinventing the wheel. At the end of the day I can get into composing a docker image that is configured just like his prod servers if I need that access, and there's likely already a docker image pre-done that has 99% of what I need, including metrics/monitoring. At which point I could launch my service on any number of hosts that allow direct pushing of built docker images, if my build process goes there. To each their own, but I think my solution requires far less time to setup and maintain, but costs more, as I said. Manually engineering each system yourself might be fun to you, but it's not to me.
- pier25 4y agoWhy not simply run the app locally with the production database? (either a copy of production or directly connecting to production instance)
- jaywalk 4y agoYou lose the convenience of being able to immediately switch back to the previous version as well as testing on identical hardware and software.
- pier25 4y agoIf you're running it in local, there's no need to switch back to the previous version. It's true about the hardware, but if you use a container it can run on the exact same software.
- chinathrow 4y agoFascinating. I have the exact same number of visits and run the site with a boring PHP/MySQL setup from a cheap but very reliable 200€/y shared hoster. Deployment via git over ssh as well.
- jason-phillips 4y agoWell done! I work on antique brass clocks.
- silverfox17 4y agoJust because it's an old method doesn't mean it's a bad method.
- dijonman2 4y agoSimplicity always wins over complexity. Complexity is a liability, but it does make you feel smart.
- geysersam 4y ago> simplicity always wins over complexity S/he wrote on a hand shaped microprocessor/wireless transmitter connected to a billion servers via 7 layers of network protocol. Ultimately her taps on the micro capacitator infused glas surface resulted in light pulses through cross ocean cables encoding her (encrypted ) words carried to hundreds of people all over the world.
- chinathrow 4y agoIs this sarcasm?
- jonplackett 4y agoSomething not mentioned but I’d like to know is the running cost?
- iLoveOncall 4y agoHe gives his server specs and his cloud provider, he pays most likely a bit less than $100 per server per month: https://www.digitalocean.com/products/droplets https://www.digitalocean.com/products/droplets Which is absolutely insane for a website that serves 200 visitors per hour.
- rurban 4y agoprobably that's why he already got white hair.
- ed25519FUUU 4y agoJust to be clear are you saying the costs are HIGH or LOW? That cost seems high given his relatively low traffic count but I don't know what sort of processing is going on in the background.
- yabones 4y ago8c/16g seems absolutely bonkers for an web/app server. I could understand if there was also a data & caching layer shoved onto the same box, but that's a LOT of memory for a python app. That's more inline with "mystery meat ASP.NET app built by some a couple guys in Slovenia 12 years ago".
- wolfspaw 4y agordd discussion: https://www.reddit.com/r/Python/comments/xobba8/how_i_deploy_my_bootstrapped_python_webapp_with https://www.reddit.com/r/Python/comments/xobba8/how_i_deploy...
- moralestapia 4y agoJust a small comment, blue/green usually implies some sort of load balancing, here OP is just flipping a switch that changes a hostname and flips the roles of blue/green from staging/production. Nothing bad with that, thought, and part of its genius is how simple it is.
- akoncius 4y agowell balancing is done on DNS level, and it’s not required to have literal loadbalancer.
- moralestapia 4y agoBlue/green usually involves moving traffic from blue <-> green gradually. You usually do this with a load balancer. That is all.
- outworlder 4y agoUsually, yes. But now some[one|thing] will have to do the monitoring and gradually ramp up traffic, rollback, etc. It's perfectly ok to immediately flip the entire traffic if you are a one man shop and your customers will tolerate it.
- abrookewood 4y agoI've never heard that the gradual moving of traffic was a requirement for B-G deployment (though it is helpful), just that you 'flip a switch' between one running server and another one.
- xani_ 4y agoYou can still do that in this kind of setup, just put loadbalancer like HAProxy on both that sends traffic to both nodes but prefers "the one that's local" in default config. Then you can use the LB to move traffic as fast or as smoothly as possible, and it also masks failures like "app on current node dies", as the traffic near-instantly switches to the other, at some small latency cost. This also gives you a bit more resilience, if the app on node dies (out of memory/disk/bug/whatever), the proxy will just send the traffic to the other node without having to wait for DNS to switch
- nurettin 4y agoI love this simple setup. Big fan. I also do everything simple. Add more workers? Just enable another systemd service, no containers. Let the host take care of internal networking. The biggest cost is probably a managed db, but if you are netting $$ and want some convenience, why not?
- ed25519FUUU 4y agoHow is adding another systemd service easier than starting another container in this instance?
- ksbrooksjr 4y agoGreat write-up. Note that the author is only serving 70 requests per second at peak with 15 thousand registered users and 3 thousand in revenue per month. This just shows that you don't always have to plan to scale to thousands (or millions) of requests per second. This blue-green deployment workflow reminds me of a similar setup used by the creator of SongRender[1], which I found about via the running in production podcast[2]. One thing to be aware of with smaller VPS providers like Linode, DO, and Vultr is that they charge per hour rather than per second. So if you boot up a new VM every time you deploy you're charged for a full hour each time. [1] https://jake.nyc/words/bluegreen-deploys-and-immutable-infrastructure-with-terraform/ https://jake.nyc/words/bluegreen-deploys-and-immutable-infra... [2] https://runninginproduction.com/podcast/83-songrender-lets-you-create-audio-visualizer-videos-from-audio-clips https://runninginproduction.com/podcast/83-songrender-lets-y...
- ed25519FUUU 4y agoI think we can safely put docker images (not k8s) in the "boring technology" category now. You don't need k8s or anything really. I like docker-compose because it restarts containers. Doesn't need to be fancy.
- BlargMcLarg 4y agoCan say the same for ci/cd. Author talks about integration tests, setting a barebones "build this and deploy it" pipeline is far more trivial and skips having to do it manually every time.
- ed25519FUUU 4y agoIt's interesting that some engineers look at docker and ci/cd and say "that's too complicated" and others look at a system without it and say "it needs to be simplified"
- BlargMcLarg 4y agoInexperience or difference in experiences. I wouldn't necessarily advocate containers as my experience has been mostly "this takes far longer than the gain" (given the OP's scenario). Meanwhile, my experience is a minimal CICD pipeline takes half an hour once you know manual deployment, and I lose far more having to SSH and run scripts myself than telling a machine to do it for me (not just time but mental satisfaction too). Though I wouldn't call either fancy in this year. Only past that stage, where the benefits drop sharply for individuals.
- intrepidsoldier 4y agoContainers are more than just Kubernetes
- spyremeown 4y agoAgreed. Containers... just work? Actually, Docker just works. It is rock solid and I'm very delighted I learnt so much of it. The only thing I'm missing about Docker is a bigger focus on on-the-fly image editing. Like, I love to have these container development environments. I'd love to give some command inside the container and make it magically appear on the Dockerfile if it was successfully executed, so I don't have to manually copy things over when I want to have reproducibility for later.
- keepquestioning 4y agoWhat is the app?
- Quarrel 4y agoHe does say, but: https://keepthescore.co/ https://keepthescore.co/
- abledon 4y agoFAQ says an upgraded board (~10$) lasts forever... surely it wont be here in 2150 CE ? I'm always curious about the word 'forever' in legal agreements, when truly do we expect a 'forever' product to go out of service.
- bakugo 4y agoMaybe I'm missing something here, but what are the advantages of having two identical servers with a floating IP that switches between them instead of just running two instances of the app on the same server and switching between them by editing the nginx proxy config?
- tjkrusinski 4y agoLess work. You'd need to have a different context for environment variables that adds another level of complexity. Likewise if you had a dependency that needs updating (SSL, etc), you can do it safely on the idle machine without worrying about production traffic.
- xani_ 4y agoEh, it's pretty trivial to do. The reason for 2 servers is high availability, not that it is easier in meaningful way. I run something similar on personal site and it's literally just 2 identical configs but with different port/directory and some haproxy config.
- noselasd 4y agoSo you can do maintenance/kernel upgrades etc. on the server that's not in production at the moment.
- endigma 4y agoI don't see why the author is so proud of avoiding tooling that would make their build and deploy process simpler? Even something like digitalocean's own buildkit based "apps" would be an upgrade here. Deploying your app using ssh and git is not magic or simple it's just a refusal to learn how actual software delivery is done. Even totally dodging docker/k8s/nomad/dagger or anything that's even remotely complicated platforms like AWS/DO/Fly.io/Render/Railway/etc obsolete this "simple" approach with nothing but a config file. I also theorize that the author is likely wasting a boatload of money serving ~0 requests on the staging machine almost all the time, due to him literally switching a floating IP rather than using two distinctly specced machines for production and staging
- kjoedion 4y agoWhat? Manual git pushes ensure the highest level of security and error avoidance. I routinely find myself having to do one-off post-deployment things that would be a nightmare to try and script into the ci flow.
- endigma 4y agohttps://fly.io/docs/flyctl/ssh/ https://fly.io/docs/flyctl/ssh/ https://render.com/docs/ssh https://render.com/docs/ssh ... and others
- bastardoperator 4y agoSay what? I can't tell if this is satire or not.
- deleted 4y ago[deleted]
- matai_kolila 4y agoAWS's CodeDeploy is magic for stuff like this. I got so many things for free when I began using it for deployments, it's kind of amazing...
- guhidalg 4y agoI disagree, avoid CI/CD tools is the right call until this grows enough that you can't continue writing small scripts. I think all the CI/CD tools are garbage in that by being generic they do a poor job at addressing your specific needs. I don't know who needs to hear this, but you don't always need to start a project by reaching for the most complex tool possible. Build up to it and then you won't need convincing to use it.
- jlundberg 4y agoUsing two servers, one for production and the other for staging/failover, then switching upon release is a neat technique. Been using it for our API backends for about ten years.
- nlstitch 4y agoIm secretly a fan of the boring tech statement. Sometimes all of the new containerization and microservice paradigms just feel like an excuse to overengineer everything. Running solo and starting from scratch (no code, no infra, no cloud subscriptions) means you'll have to simplify and reduce moving parts.
- guhidalg 4y agoYes! Boring tech is working tech, never choose an untested technology if there's any real stakes in the work.
- outworlder 4y agoMicroservices are difficult to justify with a small team (or a single person team in this case). If your monolith has obvious modules that can be carved out, you _need_ to scale them independently and for some reason you can't just deploy multiple monolith copies, then it may be worth it to do microservices. At large companies, the calculations are different. Even when monoliths would be the best fit, they may still carve out microservices. How else would they be able to ship their org chart? :)
- intelVISA 4y agoKISS but unironically
- XCSme 4y agoI still believe the LAMP stack is the future for most non-realtime applications. With PHP you just FTP copy a file to the server and it works instantly, no builds, no compilation, no restarts. Compared to Node.js the server feels a lot more robust by default and an uncaught exception doesn't bring down the whole server until restarted. The biggest plus: you can host a lot of applications on the same stack and by default ALL parts of the stack (Apache, MySQL, PHP) can handle concurrency and load distribution well (with Node.js, for example, by default each application will be mostly single-threaded, you have to manually spawn multiple Node.js instances/workers for it to properly use all the server resources).
- saradhi 4y agoI came here to see more website links with one-man shows that are beating 150k/m.
- deleted 4y ago[deleted]
- londons_explore 4y agoWhen you're a 1 man show, you need to both save your own time, and compute costs. To save your time, use the simplest thing you know how to use. Whatever you can set up easily and gets you serving a hello world on the internet. To save compute, just don't do stupid things. In particular, you should consider what happens if this project isn't a runaway success. One day, you might want to leave it running in 'maintenance mode' with just a few thousand users. For that, you'd prefer to be running on a $10/month VPS than a $2000/month cloud setup which is going to require constant migrations etc. Things like automatic failover and loadbalancing are seldom required for 1-man shows - the failure rate of the cloud providers hardware will be much lower than your own failure rate because you screwed up or were unavailable for some reason.
- hacknews20 4y agoLove this: “absolutely No Kubernetes”.
- petargyurov 4y ago> The trick is to separate the deployment of schema changes from application upgrades. So first apply a database refactoring to change the schema to support both the new and old version of the application How do you deploy a schema that serves both old and new versions? Anyone got any resources on this?
- david422 4y agoYou only do additive changes. Only add columns etc. never remove them ... until all your old application code is no longer running.
- naasking 4y agoAnd you have to weaken your schema to allow nulls for the duration that old and new code are both running (and possible foreign key constraint failures).
- petargyurov 4y agoThanks. I thought it would be something... smarter. Not sure I like that, seems to come with a lot of caveats.
- xani_ 4y ago"smarter" means more code and that's rarely more maintainable. It's what you have to do if you want less downtime. Normally it shouldn't span much more than 2-3 versions of application and it's rare that the annoying kind (say writing same data to "old" and "new" column) happens.
- outworlder 4y ago> until all your old application code is no longer running. Or until it's been disabled by feature flags.
- rwiggins 4y agoThe application needs to be developed with this constraint in mind. I’ve spent quite a lot of time over the years doing blue/green deployment advocacy and awareness for developers in some orgs. It does sometimes substantially complicate the code to build both backward and forward compatibility, but it is so nice when done well.
- dewey 4y agoI'm a strong advocate of boring technology too but I'm also very much in favor of keeping things off my dev machine. In that case they have to run ssh, git and run a script to switch endpoints. My current boring system for a simple Rails app (https://getbirdfeeder.com https://getbirdfeeder.com) is that I push to GitLab, the CI builds a docker image and does the ssh & docker-compose up -d dance. That way I can deploy / roll back from anywhere even without my computer as long as I can log into GitLab (and maybe even fix things with their web editor). Seems a lot "more boring" to me and having the deploy procedore codified in a .gitlab-ci.yml acts as documentation too.
- outworlder 4y agoMy rule is: SSH to a machine and running manual commands for any non-toy systems is an antipattern. Every time you SSH to do something, it means you are missing automation and/or observability. In small teams it's bad because it's a waste of time. In large teams it's bad because it creates communication overhead (it's also a waste of time but that can be often absorbed if things don't get too crazy). For a single person team it is bad because now they have to depend on their memory and shell history.
- emptysea 4y agoYeah it's really straightforward to setup Github/Gitlab/Circle/etc. to run your various deploy / ssh commands for you, then you don't need actually access to the box. Really nice being able to open up GitHub and manually kick off a deploy -- or have it deploy automatically.
- ithrow 4y agoFor a single person team it is bad because now they have to depend on their memory and shell history. There is this thing called shell scripts.
- outworlder 4y agoThe scripts can SSH to whatever. If someone is connecting via SSH and then running scripts, that's an issue.
- 28304283409234 4y agoOh my all the opinions again. Software is not, believe it or not, a True or False game. TIMTOWTDI, folks. This guy rocks a solid process that he is comfortable with and that works. I for one applaud him for it.
- homami 4y agoFor what it is worth, I am handling about 130k views and registering ~1k paying users per day with a t2.large instance server running node, redis and nginx behind a free tier Cloudflare proxy, a db.t2.small running postgres 14, plus CloudFront and S3 for hosting static assets. Everything is recorded in the database and a few pgcron jobs aggregate the data for analytics and reporting purposes every few minutes.
- digdugdirk 4y ago... Could you translate please? As someone who isn't a programmer (mechanical engineer) but has some programming ability, the idea of designing something like the article author did and sharing it with the world intrigues me. How much does a setup like you described cost per month? (Or per x/number of users, not sure how pricing works in this realm)
- mattmanser 4y agoThe article's a pretty simple design, and how most people used to do it pre-cloud platforms. The article's pretty much saying "you don't have to go AWS/Azure". Although back in the day we didn't really have managed DB instances, you'd often just run the DB on the same server as the app. The parent, however, is paying a lot more for a t2.large. For that kind of money you could almost get a dedicated machine which would be 10x more powerful than a T2.large, but with the hassle of maintenance (though it's not a lot of hassle in reality). The advantage of AWS is not price. AWS is quite a bit more expensive if you want the same performance. It's either that you can scale up and down on demand, or the built-in maintenance or deployment pipelines. So you can save money if you have bursty traffic, or save dev time because it's super easy to deploy (well, once you learn how). Cloud platforms can also have weird limits and gotchas you can accidently hit, like your DB can suddenly start going slowly because you've got a temporary heavy CPU query running, as they don't actually give you very much CPU with the cheaper stuff.
- cutler 4y agoHow many CPUs has your t2.large and how are you clustering Node across them?
- woopwoop24 4y agoif it was mine i would most certainly opt for ansible or something likewise, the overhead of logging into a machine and doing all the things by hand/manual is more complicated and error prone than a playbook would be (at least for me and me forgetting all the steps all the time ^^). But who are we to judge, impressive to earn 2,5k every month with it, kudos.
- tonnydourado 4y agoNot gonna lie, I was triggered by the no CI/CD and shared database between staging and prod. But those concerns where very satisfactorily addressed. I'd miss some form of CI/CD if it was a team, but I suppose that for a single person show, running tests locally is enough. I do miss infra as code mentioned. If shit goes tits up with the infrastructure and everything was setup with clicking around in control panels, ad-hoc commands and maybe a couple of scripts, your recovery time will be orders of magnitude bigger than it has to be.
- cutler 4y agoHallelujah - a bit of sense regarding the appropriate use of Docker and Kubernetes.
- altdataseller 4y agoDo u have 15k paying users or are most of them free?
- brundolf 4y agoThis is pretty close to my current (hypothetical) plan for how I'd stand up a small full-stack app as a solo dev. Only thing I didn't think about was blue/green deployment which sounds great. Glad to see a real-world case study showing that the overall strategy works well
- thomasfromcdnjs 4y agoUse use fly.io or heroku.
- koinedad 4y agoLove the simplicity and clear description, thanks for sharing!
- bemmu 4y agoI'm doing about 1M database writes per day. DB is sqlite3, server is a Hetzner instance + extra storage that costs about $4 / month total. Computers are fast.
- Tanujatripathi0 4y agoWith December approaching, sort your hampers for the dear ones in Germany with a dash of creativity and a bit of utility. That’s what makes the best gift combos. If you’re not good at handling the finer balances, take online suggestions from gifts2germany.com and send across amazing gift baskets to pals and people in Germany, at least costs. We have gourmet hampers, cakes, baked goods, wines, champagnes and many more in our Christmas Hampers to Germany , with the promise of 100% sure deliveries of 1-2 days to Germany, with absolute free shipping. Enjoy the handpicked baskets, boutique Christmas Gifts to Germany with our 24*7 customer care and seamless delivery updates. Source: www.gifts2germany.com/Christmas_Germany.asp
- simonebrunozzi 4y ago150k/m - I thought it meant kilometers per hour. It's obviously thousands per month.