Hacker Newsnew | past | comments | ask | show | jobs | submit | more BiteCode_dev's commentslogin

Talking about myself, as a python dev:

- cheap VPS for hosting, postgres for the db, nginx as a proxy, redis for everything else, including caching.

- deploy python projects by packing them as zipapp with shiv, then use fabric to ssh and performs any migrations necessary. No, not even ansible.

- build, lint, format and test, like all automatizable stuff, are made using pydoit. If you are solo, you don't need a CI service. Your laptop is the CI machine.

Scaling is always the same story:

1 - start with the cheapest VPS possible. This will force you to code with some constraints. Not crazy, just enough to balance it out.

2 - once you start seing your load average rising, just move the db on a second cheap VPS. You just tripled the load you can sustain. Not doubled, tripled. Most solo projects will stop here actually.

3 - wait again, collect some perfs data when you see the site starting to be slow. Check for slow queries, code hot paths, etc. Optimize that, add some cache, setup tasks queues. Use cron to purge / regenerate cache if you need to smooth out the curve. Maybe slap some varnish for extra peps, or just cloudflare.

4 - now you got what looks like a real load, and a more realistic code base, so when you peak again, request more perfs for your server, or migrate to another bigger one. You can scale vertically to crazy highs nowadays. Really, really crazy. You can get terabytes of RAM, 64 cores servers, etc. At your current scale, your service should generate enough money to pay 10 times for it anyway. But you probably won't need to. Even cheap servers are beast, look at the current leaseweb offer: https://www.leaseweb.com/dedicated-servers#NL

For €320.09 per month, you get:

    2x 16 cores 2.30GHz
    28GB DDR4
    4x960GB SSD
    30 TB traffic
To put it in context, myspace used to serve all its users with 2 servers only, until they reached 500,000 accounts. Only then it was too much. This was with hardware (and price!) in the years 200x.

5 - you will probably never reach this point. This is the point where kubs, load balancers, sharing, etc. start to be interesting.

How to preserve your data:

- Raid

- Dump the db with a _randomized_ cron

- rsync the dump and all assets. You can do it to another server, or just your laptop at the beginning.

You can get fancy with database replication if you want, or use backups that stream in real time.

But there is one trick: not all data are equal. Identify some data in your db that you can't afford to lose, and make sure this one is saved separately and very regularly while being given priority. There are plenty of data, if you have a hole in it, most people don't care. E.G: if 1 tweet out of million from 10 years ago is missing, do you think it affects the service?

Monitoring:

- Sentry

That's all. It's free (or cheap), and for a small service, you don't need real time. It's ok to be down a few hours once a month for most services at first. I have a service with 700k unique users a day, it still goes down sometimes. It's a blip.

Sometimes, log into the servers, run htop and checks what's up. You can install open telemetry later if you really need to, but for now, even HN hug is not going to kill you.

Summary:

- Modern software and hardware are amazing. Max them out. Horizontal scaling is hard, and expensive.

- You don't need a perfect service. Unless you are handling patient cancer data, that is. Don't worry about perfect uptime, 0 data loss, etc. If you are a solo dev, the cost for that is huge. Just do 97% right⋅

- what worked 20 years ago still work today, and will likely be there tomorrow. And you can move from that to the cloud later. The reverse is not that nice.


People are renting 32 cores for E$320/mo?

...Anybody wanna rent 56 cores and 128GB of RAM for that rate?


If you can give the guarantees and convenience that lease web give, then yes.

Is your bandwidth unmeterred?

Do you have redundancy everywhere, including link and power?

Do you have software to remotely manage the server, including install, reinstall and emergency access?

Can I pay you with the company credit card? Do you provide a billing system with VAT?

If the answers are yes, then congrats, you can open your own hosting business.

But remember next year, the servers will be obsolete.


You did that, as a solo dev with little money, and made a profitable business out of it?


not quite yet ;)

ps some of the google cloud next announcements today around appsheet, appscript, looker, ai vertex notebooks, and "no-code" solutions are starting to look really sophisticated!


Well, we know that mass surveillance has been installed in the USA, we have detailed proof of it, and this hasn't change a thing. They are still under mass surveillance.

And people are still carrying trackers in their pocker. They put cameras in the front door bell, always online microphones with speech analysis in their living room, give all their life records, textual or in images, to giants companies that have demonstrated the ability to store and analyse that forever.

People don't use more free software. They look at you like you are mad if you don't want to install whatsapp. Even in HN we have people still wondering why we should use Firefox.

Why would we be judging Australians as "complacent" ? Humanity is complacent.

I've been told the boiling frog is a myth, but I'm pretty sure frogs are talking about boiling humans as a telling metaphore.


This literally is the divide between HN types and everyday individuals.

The latter pays little attention because they generally do not care whilst HN will debate and suggest endless fixes to the problem - which are always technically more difficult or cumbersome. This is why people buy Apple products on each iteration, religiously for some, because they want it to work, be pretty and the desire of everyone.

The UK has been well known for their love of CCTV and yet crimes still go unpunished and people don't get caught.


I wouldn't say ordinary people "do not care". To some extent, even ordinary people know that the mega tech empires concentrate too much power and data. Popular media hasn't completely failed to report on stuff like FB fiascos, privacy leaks and so on. Many more people are aware than HNers might imagine. But viable solutions are not there. As you point out, alternatives are workable only to the technically inclined, which means they might as well not exist. To be sure there are alternatives which swap one silo for another, but truly private options are too cumbersome to make inroads into mainstream, and they never will, if they continue to remain so fiddly. Of course the other side of this is legislation and regulations but even here the transnational nature of these corps allow them to work around even progressive national laws, and the latter are rare enough, with most politicians bought off one way or another.


While it's definitely true that humanity is complacent overall (clearly), there are some very important differences between the US and Australia.

Australia has actually moved on ending secure encryption for example. That's not yet the case in the US and it's questionable whether the authorities will be able to (they already would have, if they could have), overcoming the significant constitutional hurdles.


There is no need to end encryption in the USA, because the way they collect the data works around the problem entirely.

With secret subpoenas, gag orders and programs like PRISM, they get what they need directly from the source. Either from the services hosting the data, or the devices producing/receiving the data.

The data is never collected while in transit, when it's encrypted. They got the keys for the servers, and back-doors to our devices. They don't care about encryption at all.

Once again, freedom is not a technical problem:

https://xkcd.com/538/


Yes but self driving cars, which could be a solution for this problem since we could then have cars on demand, are way harder to implement using oil than electricity.


unsafe rust code is not safe, but the rest of the program is, and the unsafe blocks provides very nice benefits:

- limit the size and scope of the unsafe code

- make the unsafe part stand out, "here be dragons", so you know when to be particularly alert

- act as a safe way to encapsulate unsafe code so that it can be used by safe code, and used without the lack of safety propagating outside of the unsafe zone


Yeah, and didn't seem reluctant at all at the time.


they just shrugged back then

"But calibrating that response raises questions of principle, practice and priority. Businesses will go their own way. Some, such as PayPal, Visa and MasterCard, which handled donations to WikiLeaks, and Amazon, which provided web-hosting services, have dumped it as a customer in response to American outrage. More may follow. They risk attacks from its fans, just as those that refuse face hostility from their customers in America. Too bad: business is full of hard choices."

https://www.economist.com/leaders/2010/12/09/the-right-react...


I remember this whole thing. No one was ever reluctant! It happened pretty quickly.


Every single time there’s a HN discussion about censorship and I comment about how we shouldn’t be okay with censorship of anyone regardless of how offensive they might be or whether or not it’s some private corporation and usually it gets downvoted. When the wind starts blowing the opposite direction, only then do people wake up.


So you demand freedom for all ... except those that are using their freedom in the way you dont like.

For the avoidence of doubt, I am talking about the freedom to not have someone in your house / your company platform.


No, they demand a principled balance between the two freedoms, that's independent of the content of the speech. What you're talking about is what's status quo - freedom for private businesses to not serve someone, except when it contradicts certain narratives, at which point it becomes a national news story about bigoted business owners.


Saying the balance should be predicated on ignoring the content of the speech makes sense only if speech itself was a pure function without side-effects, only if saying something truly had no other consequence than it being said can we safely ignore the content.

But the precise content of speech is exactly the part that matters! If a death sentence is read out aloud in verse, or just sent in via a short text message (that is via two very different types of speech) is clearly not very important if the end result in either case is an aid worker being blown up with a Hellfire. Speech very often triggers actions, to ignore this fact is to state nothing may be prevented because judgment is only possible by examining actions committed to reality.


> we shouldn’t be okay with censorship of anyone regardless

That is not a balance, that is an absolute position in favour of one side of the coin ... regardless


The "balance" is based on something that, while explicitly stated, you somehow disregarded: that some--and, by and large, the current legal landscape--considers the freedom of speech right of the platform to censor people, and so to obtain "anyone can say anything" we have to take away "the freedom to not say something"... which we actually already do in various instances (often involving protected classes) and so, personally, I consider that to be a tractable goal to regulate: some things are "utilities" or even "quasi-governmental entities" and should be forced to be something like a common carrier.


So, if i would manage to besiege the city of rome, conquer it and declare the forum romanum mine, and to throw out all the romans. Does that make writing "Romanes eunt domus" an act, that forbids you forever the usage of my conquered streets? M i the conqueror allowed to sentence a citizen to house-arrest, by defining social negative space?


You are as free to forbid the speech as those are free to make the speech.


Social media companies which are actively working with the government to censor opposing view points while also enjoying legal immunity from lawsuits. You think there’s a fair balance of “freedom” here? Should telecom/electricity/railroads also get to ban whoever they like? Did you support net neutrality?


The false equivalence here between your house and your company platform is so ick.


I take it you dont believe them to both be private property?


A home can't take credit card payments.


Every single one have fake data, guaranteed. I have yet to see a public facinh site I worked on that didn't have some fake data.

Some outrageously fake, like x10 times the user count.


Unfortunatly you often can't use -o because of the 3rd party libs that didnt' get the memo and use assert for error checking.

We still have -X dev and sys.flags but it's runtime only.


Unless I'm misunderstanding, they are wrapping their asserts in try/catch blocks? That's... yikes.


Most likely they just `assert` error conditions and let that blow up as error reporting, rather than write a full conditional and raise a custom exception.

I’ve been guilty of that in my own code when I just want to tell myself about an error.


Isnt just assert the error condition how assert is actually intended to be used?


Depends. The issue is that since `assert` is stripped out in “O” mode, if the codebase depends on `assert` for correctness… they’re not compatible.


What do you mean by depends on assert for correctness? How?


    get_president_inside_bunker()
    assert president_is_inside_bunker()
    close_bunker_doors()
    assert bunker_doors_are_closed()
    send_nukes()
With asserts enabled this is fine. With asserts disabled you might start sending nukes while the president is still outside or the doors to the bunker are still open.


Thanks! I never thought anybody would do such a thing.


No one should, but it happens.


Care to name any 3rd party libs in particular?


Nope, I just remember my server crashing years ago so I stopped ever since.

Would be interesting to scan pypi and check if this is still a thing.

Maybe create a bot warning lib authors.


Seems like a better idea would be to make a separate flag "--remove-assertions" for people who desire that.


"-o" is mostly "--remove-assertions" already, so that wouldn't help.

While today's use case for assert is unit testing, the actual killer feature of the keyword is that it's removed only from prod.

The idea is that you can write things like function contracts, that are expensive, but only exist in dev.

Now, if one of you dependencies use assert for something they expect to still be in prod, which is the problem we are talking about in the first place, "-o" or "--remove-assertions" will strip their assert too, breaking their code, and hence, yours since it depends on it.


Before this thread i had no idea assert was debug only in python.

Another solution would be to accept the current role of assert as quick error checking and add in debug_assert to indicate a conditional error check. The biggest issue with that approach is that a majority will suddenly ask "Wait, python has a debug mode?"


Not because the -o mode also remove any block testing on "__debug__", and that's a very useful thing as well.

The original feature is perfect. But there is 5 good years of educating users so it can be used.


I still do not understand what the problem is and what users need to know. So assert throws and exception in debug mode and is 'commented out' in production, right?

So the problem is some vendors ship libs that have failing asserts so cannot run in debug mode?


Starlette, SQLAlchemy.


Django Rest Framework.


It's pretty well done, I almost forgot I was in my shell, and when the games gets to "tree to map the dungeon", I was almost surprised I didn't think about it before: I felt like playing a game, not coding in bash :)


It's fun and probably useful, but Python is not 30 times slower than lua (from 33s to less than a sec).

The 2 codes don't do the same thing, if you perform the same computation on the python code (monochrome mandelbrot, inline loop, 49 iterations, etc), you get 0.8 vs 4.8 sec, which seems about right.

I've removed numpy since it's cheating if we compare raw language perfs:

https://0bin.net/paste/nOtLmeMA#0DKGHSvmgoDLPzHlQOhwvVhxxayf...

So yes, Python is about 6 times slower. Significative, but can be worth the compromise if you consider the Python version is much, much easier to read.

And of course, a vectorized algo would be even faster (see pbourke's comment).

What's more, with SharedMemory from 3.8, you could speed that up even in pure Python using multiprocessing by sharing efficiently the array.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: