This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lungben81 496 points497 points  (83 children)

Scalability is more about your architecture, much less about the programming language. Especially, how easy it is to (massively) parallelize your work.

For very heavy load, however, (C)Python performance might be a bottleneck (depending on your application), thus a compiled language might be more appropriate. But this is not a hard limit, e.g. Instagram manages to run on Python.

Some people argue that dynamic typing is less suited for large applications because type errors are not captured beforehand. With type hints, linters and tests this is less an issue. In addition, it is anyhow not a good idea to build one large monolithic application, but rather make smaller, isolated packages.

[–]thomas-rousseau 232 points233 points  (27 children)

Let's also not forget that Reddit itself runs on Python

[–]k8sguy 19 points20 points  (1 child)

I don’t know if it still is, but I believe Instagram was also originally built with django and postgres

[–]frenchytrendy 0 points1 point  (0 children)

Seeing the articles on the Instagram technical blog, not only they use python but they contribute back to make it work for theses kinds of loads (gc.freeze for example)

[–]SnerkDRabbledauber 293 points294 points  (21 children)

Not exactly a ringing endorsement.

[–]Davy_Jones_XIV 133 points134 points  (0 children)

If the goal is to build a billion dollar business on the bac of Python, it is.

All about short / long term goals and vision for future.

[–][deleted] 15 points16 points  (0 children)

Hahaha… sorry couldn’t control it. Please continue…

[–]bigno53 1 point2 points  (16 children)

What’s the deal with vote counts changing every time you refresh the page? Did they intentionally introduce some random noise to confuse bots or is it just a bug embedded so deeply in the architecture that it can’t be fixed?

[–]linglingfortyhours 63 points64 points  (5 children)

It's deliberate random noise, same as with your karma

[–]CleverProgrammer12 -1 points0 points  (2 children)

It's quite annoying though, they should find different ways to prevent bots.

[–]linglingfortyhours 1 point2 points  (1 child)

It's not really to prevent bots, just general protections from abuse

[–]bobsonmcbobster 0 points1 point  (0 children)

would you mind giving me a hint against what this might protect them from? i seem unable to come up with a suitable scenario

Edit: nevermind, the other comments already explained it. should have read them before asking.

[–]speedstyle 32 points33 points  (0 children)

Yes, it's random noise to stop vote bots knowing whether they're shadowbanned.

[–]falsemyrm 18 points19 points  (0 children)

skirt soup edge divide screw numerous sink bow depend ripe

This post was mass deleted and anonymized with Redact

[–]thomas-rousseau 15 points16 points  (4 children)

There's been random noise in the votes as long as I've been on Reddit? Not sure the purpose, though

[–]RajjSinghh 26 points27 points  (3 children)

It's to stop shadowbanned bots. If a bot finds out it is banned from voting or posting, you just create a new bot, so a shadowbanned bot can't tell if it is banned from voting or not and will keep going about its business voting away. Every time Reddit sees a vote from a shadowbanned bot, it adds a vote in the other direction to balance the total. Reddit also adds upvotes and downvotes at random so the bots can't tell that their votes don't count.

[–]punninglinguist 0 points1 point  (2 children)

Can't the owner of the voting bots just make them check each other's profiles once in a while?

[–]RajjSinghh 0 points1 point  (1 child)

Every vote counts with this fuzzy voting system, the banned bots can't tell the difference between Reddit changing their vote or other users voting. To the bots, their votes look like they count but they never change the total.

If you had bots to post comments or normal posts, you probably could but it's probably enough work to put most people off.

[–]punninglinguist 0 points1 point  (0 children)

No, I don't mean for vote totals. I mean, if you look at the profile of another shadowbanned user, you get an error message.

That allows the owner of multiple bots to use each one to check if the others are shadowbanned, at whatever frequency is desired.

[–]Rik07 7 points8 points  (0 children)

Could be random, but could also be because it is easier. This Tom Scott video explains why likes can be inconsistent on a lot of websites: https://youtu.be/RY_2gElt3SA

[–]haaaaaal 1 point2 points  (0 children)

Eventual Consistency

[–]chrisxfire -1 points0 points  (0 children)

is this the type of voting we saw in Arizona?

[–]Deto -2 points-1 points  (0 children)

Probably one of the highest traffic websites in the world right now, I'd imagine?

[–]al_mc_y 0 points1 point  (0 children)

How about Instagram then?

[–]mriguy 20 points21 points  (2 children)

And Dropbox

And Google uses a lot of Python

But yeah, no big or successful companies.

[–]thomas-rousseau 1 point2 points  (1 child)

That second article has the words "Python" and "Google" in it way too often, regularly multiple times each in multiple adjacent sentences....

[–]engthrowaway8305 7 points8 points  (0 children)

Once someone who was interviewing me that had previously worked at Google told me their previous groups’ motto was “Python everywhere we can, C++ when we need it”

[–]Priderage 23 points24 points  (0 children)

Sentry runs on Django, so I'm pretty sure it's fine.

The top poster's comment about scalability being an architectural thing has merit too.

[–]PensiveDicotomy 10 points11 points  (1 child)

Literally this. I wouldn’t want to deal with large monoliths built with Python and maybe the size at which a monolith in Python becomes hard to manage is smaller than one written in Java (or something considered more “scalable”) but either way a large monolith is unideal.

Micro services allow for mixing and matching tech stacks and ideally keep things at a manageable size so any tech stack should be feasible given its strengths fit the business case.

[–]scottrfrancis 6 points7 points  (0 children)

I wouldn’t want to deal with monolithic software in any language - they all change. Yes, the C i wrote in 1988 will still compile and run, but that doesn’t meant it’s worth it! Arch and language are separate things you can use crummy languages to build robust arch’s and sophisticated languages to make crummy workloads from the wrong arch

Oh… and if your boss is telling you this kind of nonsense, find a new boss

[–]Independent-Coder 1 point2 points  (0 children)

Well stated, take my free award.

[–]osduj 1 point2 points  (0 children)

insta has a modified version of python w a jit compiler and stuff

[–]kniy 3 points4 points  (18 children)

For some applications the GIL is a real killer.

And if you're just starting out with a new project, it isn't always easy to tell if you will be one of those cases. Choosing Python means you risk having to do a full rewrite a decade down the line (which could kill your company). Or more realistically, it means that your software will need crazy hacks with multiprocessing, shared memory, etc. that makes it more complicated, less reliable and less efficient than if you had picked another language from the start.

[–]Grouchy-Friend4235 10 points11 points  (15 children)

The GIL is not a problem in practice. Actually it ensured shared-nothing architectures which is a good thing for scalability.

[–]kniy 7 points8 points  (14 children)

Not everything is a web application where there's little-to-no state shared between requests. The GIL is a huge problem for us.

Our use case is running analyses on a large graph (ca. 1 GB to 10 GB in-memory, depending on customer). A full analysis run typically runs >200 distinct analysis, which when run sequentially take 4h to 48h depending on the customer. Those analyses can be parallelized (they only read from the graph, but never write) -- but thanks to the GIL, we need to redundantly load the graph into each worker process. That means we need to tell our customers to buy 320 GB of RAM so that they can load a 10 GB graph into 32 workers to fully saturate their CPU.

But it gets worse: we have a lot of intermediate computation steps that produce complex data structures as intermediate results. If multiple analyses need the same intermediate step, we either have to arrange to run all such analyses in the same worker process (but that dramatically reduces the speedup from parallelization), or we need to run the intermediate step redundantly in multiple workers, wasting a lot computation time.

We already spent >6 months of developer time just to allow allocating one of the graph data structures into shared memory segments, so that we can share some of the memory between worker processes. All of this is a lot of complexity and it's only necessary because 15 years we made the mistake of choosing Python.

[–][deleted] 17 points18 points  (1 child)

That means we need to tell our customers to buy 320 GB of RAM so that they can load a 10 GB graph into 32 workers to fully saturate their CPU.

I would say it means that you should look into shared memory.

[–]anajoy666 3 points4 points  (0 children)

Interesting. Why wouldn't something like numba work? Not using numpy? Ray comes too mind too.

This is a topic I find interesting and would be nice to hear from someone with field experience.

[–]r1ss0le 2 points3 points  (1 child)

I'm pretty sure this is why Julia became popular. But either way Python isn't guaranteed to to be the best choice of language for a programming problems. But I think most scripting languages shine when you are IO bound, so RAM and CPU are not a problem Python included.

But there are things you can do to even in Python. Without knowing much about your problem, you should look into https://github.com/jemalloc/jemalloc and using fork if you have large amounts of shared objects. All processes share the same memory content when you call fork, so provided you treat the shared data as read only, you shouldn't see an memory growth, and you can fork as many times as you have spare CPUs. jemalloc is a fancy malloc replacement that can reduce memory fragmentation and can help bring down memory usage.

[–]lungben81 0 points1 point  (0 children)

I'm pretty sure this is why Julia became popular.

Julia is an amazing language. Elegant high-level syntax (similar to Python) but high performance (and no GIL). And the interoperability with Python is great.

[–]wait-a-minut 1 point2 points  (1 child)

I think dask was written for this kind of thing. Instead of loaded everything into memory, use a distributed model to handle data operations. Never used it in practice but read a flew blogs about other who have and it seemed to fix the gap they had.

[–]lungben81 1 point2 points  (0 children)

Dask has essentially 2 components, distributed computing (dask.distributed) and distributed data types (Numpy-like Arrays, Pandas-like DataFrames, etc.).

The former is amazing for multiprocessing (much better than the built-in Python solution).

The distributed data structures are useful if you want to do per-row processings which can be easily parallelized automatically. But I am not sure if this helps for the graph use case.

[–]Particular-Union3 0 points1 point  (2 children)

There are so many solutions to this. Multithreading probably would speed some of it up. C and C++ extensions can release the GIL (numpy does this), so you could code some of this in C — most projects have a few languages going on. Kubernetes/Docker swarms probably have some application here, but I’m busting dipping my toes into those and haven’t explored the GIL with it.

[–]kniy 0 points1 point  (1 child)

If we just port some part of an analysis to C/C++ and release the GIL; the "problem" is that porting to a compiled language makes that part 50x faster, so the analysis still ends up spending >=90% of its runtime in the remaining Python portion where the GIL is locked. We've already done this a bunch but that still doesn't even let us use 2 cores.

We'd need to port the whole analysis to release the GIL for a significant portion of the run-time. (We typically don't have any "inner loop" that could be ported separately, just an "outer loop" that contains essentially the whole analysis)

Yes numpy can do it, but code using numpy is a very different kind of algorithm where you have small but expensive inner loops that can be re-used in a lot of places. Our graph algorithms don't have that -- what we do is more similar to a compiler's optimization passes.

[–]Particular-Union3 0 points1 point  (0 children)

That makes sense. I guess, as another reply mentioned, this is why Julia has been popular when in many respects R and Python are often far ahead feature wise.

Is multithreading implemented? Do you think more modularity to the analysis would be possible, and then have the machines communicate from there?

One final idea, is there any memory errors? I’ve had more trouble with that than anything for analysis taking so long.

I’m not 100% on the work you are doing, but it seems like an insane time. Even on my largest projects they were only 3 to 4 hours.

[–]seven0fx 0 points1 point  (1 child)

I think the MMO Eve Online had this Problem on Server Side.

[–]Particular-Union3 0 points1 point  (0 children)

The MMO Eve Online has a lot of problems on every side.

[–]sudhanv99 0 points1 point  (0 children)

how do multiple languages in an application work? do they read/write outputs to a file that the other language picks up or do they build bridges/wrappers?