News for hackers. Stuff that matters.
Re:Costs of running a Python webapp for 55k monthly users by tsumnia on Friday September 04, 2020 @02:23AM (#24372248)
Not to sound mean, but if there aren't posts/blogs/whatever explicitly telling people how to minimize costs... then they'll continue to follow the ones that make them pay $100+.
Re:Costs of running a Python webapp for 55k monthly users by aahortwwy on Friday September 04, 2020 @02:40AM (#24372316)
Don't do blue-green deploys when you have no revenue. Downtime costs you nothing and at 3,400 visitors a day you'll be lucky to drop a single request while deploying.

Pre-compute and cache to reduce your need for beefy servers.

When you can run something on your machine or in the cloud, choose your machine.

EDIT: It's less about saving money and more about not spending it.

EDIT2: Forgot to mention: use SQLite.

Re:Costs of running a Python webapp for 55k monthly users by stevekemp on Friday September 04, 2020 @03:16AM (#24372531)
Caching is, in general, a good thing. But it's worth thinking about how you do it. I recently sped up a large system by dropping the use of redis entirely - because it was being badly used.

During a single request there might be 50+ cache-lookups, each taking a round-trip to a remote redis server to fetch a single key at a time. Batching those up to a set/hash would have been more efficient, but the codebase had evolved in such a way as to make that difficult.

Instead of making 50+ redis fetches it turned out that just fetching all the stuff from the database was faster.

(There will be refactoring to batch up the key fetches, but for the moment there was a measurable increase in performance under current loads just by removing redis.)

Re:Costs of running a Python webapp for 55k monthly users by aembleton on Friday September 04, 2020 @04:54AM (#24373093)
Couldn't you have cached locally using something like ehcache?
Re:Costs of running a Python webapp for 55k monthly users by stevekemp on Friday September 04, 2020 @08:08AM (#24374200)
Perhaps, yes. It was the latency of the network calls that was killing performance, so something local, or even redis on localhost, would have been better.
Re:Costs of running a Python webapp for 55k monthly users by limteary on Friday September 04, 2020 @04:00AM (#24372770)
Why use SQLite?

My postgres process doesn't come close to using up enough resources to push me out of even the cheap VPS tiers and I don't have to worry about locking if there's a heavy write load.

Re:Costs of running a Python webapp for 55k monthly users by theshrike79 on Friday September 04, 2020 @05:25AM (#24373266)
Backing up an SQLite database is as simple as copying a single file. As long as nothing is writing in the file, you're good.
Re:Costs of running a Python webapp for 55k monthly users by mattmanser on Friday September 04, 2020 @05:46AM (#24373397)
That's not a reason.

Plus setting up a nightly back up of any SQL database, regardless of creed, is like a 10 line cron job.

Re:Costs of running a Python webapp for 55k monthly users by ClumsyPilot on Friday September 04, 2020 @07:57AM (#24374131)
Some developers have never written a cron job.

I think the point here is, SQLite setup would provide satisfactory results at this scale.

If the choice is betweeen a PAAS database offering and SQLite, you can pick SQLite. If you have skills / are prepared for managing dbserver yourself, then do that.

Re:Costs of running a Python webapp for 55k monthly users by aahortwwy on Friday September 04, 2020 @05:47AM (#24373406)
Yeah, fair point. From a cost standpoint it's more about using the same server for your application and your database.
Re:Costs of running a Python webapp for 55k monthly users by chillfox on Friday September 04, 2020 @03:01AM (#24372451)
SQLite Really is a bit of a hidden gem.
Re:Costs of running a Python webapp for 55k monthly users by rapsey on Friday September 04, 2020 @03:29AM (#24372609)
Not really hidden when it is one of the most widely deployed pieces of software on the planet.
Re:Costs of running a Python webapp for 55k monthly users by bigiain on Friday September 04, 2020 @03:40AM (#24372655)
Sure, but as an underlying dependency for iOS/Android, it's pretty well hidden from casual users...
Re:Costs of running a Python webapp for 55k monthly users by krtkush on Friday September 04, 2020 @04:11AM (#24372825)
That's true for even a casual website user. They have no idea or care about the underlying database.

Every app developer is aware about SQLite.

Re:Costs of running a Python webapp for 55k monthly users by chillfox on Friday September 04, 2020 @03:40AM (#24372661)
I guess not in absolute terms, but it’s mostly overlooked for web apps.
Re:Costs of running a Python webapp for 55k monthly users by TekMol on Friday September 04, 2020 @02:29AM (#24372270)
Ok, here is a quick tutorial:

Step 1:

Copy Peter Levels stack:

https://www.nocsdegree.com/pieter-levels-learn-coding/

If he serves hundreds of thousands of monthly users and makes a million a month with a single VPS, you certainly won't have scaling issues when you start out or just have tens of thousands of users.

Step 2:

If you really scale beyond that, resist the urge to bloat your stack. Think long and hard about every piece you add to it. Really understand each piece you add to it. Don't fall into the trap of paid services. Don't fall into the trap of "best practices".

Re:Costs of running a Python webapp for 55k monthly users by renewiltord on Friday September 04, 2020 @03:51AM (#24372723)
Haha, the man is clearly a beast of a product designer and executor. I don't think I would succeed with the same tools.

Honestly, spending $200/mo is insignificant to me. And I'm pretty happy to answer the question of "Why can this guy build this thing on a single VPS and you can't?" with "Well, because he's better than me".

I can be up in 15 mins on Heroku with a Rails+React web app. And in an hour have a thing. Or for a static no-login thing, faster with Netlify.

But it doesn't matter. Because I never made a product as nice as the one he made. If the outcome is I'm -$200/mo that is irrelevant to me. If the outcome is I'm +$50k/mo that is very relevant. So I'm going to optimize for how I can do the latter.

Re:Costs of running a Python webapp for 55k monthly users by chillfox on Friday September 04, 2020 @02:59AM (#24372435)
I don’t know how many times I have seen “best practices” used as excuse to avoid thinking. Usually by people who don’t even have the problem that the supposed “best practices” is meant to solve.
Re:Costs of running a Python webapp for 55k monthly users by tsumnia on Friday September 04, 2020 @03:10AM (#24372494)
While this article has steps in the right direction, it's a lot of "use this thing". I operate a simple Flask/PostgreSQL webapp for CS Education through the luxury of my university. If/When I graduate from my program, what are the aspects I can do to minimize my costs for hosting the app? Of course I'll look for best approaches but why does that need to be forbidden knowledge known to a select few?

Its an aside, but the mentality of "let them figure it out" is a major issue in education. Foundational knowledge should be easy to acquire so I can worry about higher level thinking issues. Literally spending hours trying to figure out how to set things up through hours of Googling doesn't really help that, nor does it promote the "figuring it out" people think it does - its just stumbling upon the right set of commands that let me move past this particular hurdle.

From the devops perspective, what about telling someone how to set up their own server to do/minimize X is so taxing?

Re:Costs of running a Python webapp for 55k monthly users by richiecute on Friday September 04, 2020 @04:26AM (#24372917)
I run a cheap website and here is what I do

- cloudflare free tier for caching, DNS, page rules, etc

- run everything on one VPS(digital ocean, linode, etc) pick cheapest that has specs you need

- any non-trivial storage (media, big files) move to Backblaze B2 it's cheap (you can use free tier cloudflare workers to redirect to B2 for free bandwidth due to Bandwitdth Alliance)

- free static page from Netifly (I can redirect to this with cloudflare in case my VPS falls over or something to provide info/links)

- If I want to look at logs or something I rsync it my local machine (if I cared I could set up a process to push logs/backup etc to private B2 bucket)

You may not need exact same setup, I am optimizing for caching and cheap storage because my site stores/serves lots of media files.

Re:Costs of running a Python webapp for 55k monthly users by yabai_yatsu on Friday September 04, 2020 @05:05AM (#24373156)
>Literally spending hours trying to figure out how to set things up through hours of Googling doesn't really help that, nor does it promote the "figuring it out" people think it does - its just stumbling upon the right set of commands that let me move past this particular hurdle.

That's basically all of software development for your entire career. Never not had a day or a week not like that.

Re:Costs of running a Python webapp for 55k monthly users by tsumnia on Friday September 04, 2020 @11:45AM (#24375987)
That is true and I recognize the purpose of being a proficient Googler; however my concerns stem out of the idea that learning many of those skills are not taught at all or expected to be learned in situ through programming assignments.

Here are examples of what I mean:

- An undergraduate Networking/Security course may not provide practice on appropriately salting passwords. It is merely discussed as part of some larger conceptual model. Students are browbeaten in earlier courses to not simply copy/paste code they find on the internet

- Debugging practice has to come from the student's own generated code, but if they made a mistake, they already are showing they do not fully grasp the material. There have been efforts to explicitly train debugging [1] but they are still in early stages of researching their benefits.

[1] The Code Mangler - https://dl.acm.org/doi/pdf/10.1145/3017680.3017704

Re:Costs of running a Python webapp for 55k monthly users by yabai_yatsu on Friday September 04, 2020 @04:29PM (#24378590)
Yeah there should be debugging classes, googling classes, and how to orient yourself in a massive, existing codebase classes.
Re:Costs of running a Python webapp for 55k monthly users by tsumnia on Friday September 04, 2020 @11:31PM (#24381218)
I don't think they need to be explicit courses, since that means making credits and charging students more. Rather, my research is about providing exercises specifically targeting those lower level skills. Since many of them are only a fraction of the "programming problem", they are do not require the expected hours and can be completed quickly. My hypothesis is that doing these types of problems will help reduce the time on task for coding.
Re:Costs of running a Python webapp for 55k monthly users by srtjstjsj on Friday September 04, 2020 @10:21PM (#24380896)
If I have a "million a month" business (which is coming from rich recruitijg fees on a trivial website, not amazing tech), no way am I sweating $171/mo in server bills.
Re:Costs of running a Python webapp for 55k monthly users by young_unixer on Friday September 04, 2020 @03:06AM (#24372477)
> PHP (He doesn't use any frameworks like Laravel)

I wouldn't want to read (or write) that code, but thanks for the article.

Re:Costs of running a Python webapp for 55k monthly users by paul_f on Friday September 04, 2020 @04:58AM (#24373118)
Well, aren't you special. How about staying on topic and not dropping in this, what, developer virtue signaling?
Re:Costs of running a Python webapp for 55k monthly users by afarrell on Friday September 04, 2020 @06:54AM (#24373794)
> staying on topic

A major subtopic of this thread is "different situations call for different setups."

Saying "I won't work with PHP" is like saying "Gluten will make me shit my brains out." It is not virtue signalling.

Re:Costs of running a Python webapp for 55k monthly users by rapsey on Friday September 04, 2020 @02:28AM (#24372262)
Or people could do some quick research what options there are. Not everything needs to be spoon fed.
Re:Costs of running a Python webapp for 55k monthly users by fock on Friday September 04, 2020 @02:28AM (#24372266)
basically most people don't do that for saving costs, but just because it makes sense to them. And there's lots of tutorials explaining how to run your own webapp.