News for hackers. Stuff that matters.
Re:Back end of Meta Threads is built with Python 3.10 with s... by taopai on Thursday July 06, 2023 @09:20AM (#36615320)
Thanks for your comment. I'm really interested in this topic. How do you know the web server is Django? I searched but couldn't find this.

Why would they use Django? I did some small projects in it but I assumed it wasn't very fast and wouldn't be suitable for a big app like this. I would like to know the pros and cons. Why didn't they build up something in C++ or Rust? Won't python limit the speed of responses despite being build the hard stuff in compiled languages? Sorry for being so naive, I am an amateur.

Re:Back end of Meta Threads is built with Python 3.10 with s... by dporter on Thursday July 06, 2023 @09:28AM (#36615435)
At least a few years ago, most of Instagram’s server side code was in Python. Python may be slower than C++, but it’s not about raw speed it’s about being “fast enough.”
Re:Back end of Meta Threads is built with Python 3.10 with s... by leodriesch on Thursday July 06, 2023 @09:24AM (#36615373)
It is fairly normal to build web servers in a way so they can be scaled horizontally (more instances rather than larger instances). So they can just have more containers run their Django servers and distribute the load between them.
Re:Back end of Meta Threads is built with Python 3.10 with s... by tinco on Thursday July 06, 2023 @10:44AM (#36616726)
They deemed getting to the market fast was more important than hardware costs. If their architecture is good, then they were probably really quick and flexible using Python to glue their architecture together which would have been the development bottle neck to getting the service up and running. All the components of the service can be done by separate teams in whatever language they deem most effective.
Re:Back end of Meta Threads is built with Python 3.10 with s... by DarkNova6 on Thursday July 06, 2023 @11:02AM (#36617076)
Most of Facebook is built on PHP. I’m surprised they didn’t choose Laravel.
Re:Back end of Meta Threads is built with Python 3.10 with s... by cptcobalt on Thursday July 06, 2023 @11:29AM (#36617540)
Laravel is not a requirement to use PHP effectively.
Re:Back end of Meta Threads is built with Python 3.10 with s... by DarkNova6 on Thursday July 06, 2023 @01:17PM (#36619387)
Oh, I know. But as a joke I chose the most well known framework.

Personally evren I prefer php over python.

Re:Back end of Meta Threads is built with Python 3.10 with s... by yurishimo on Thursday July 06, 2023 @11:28AM (#36617533)
Laravel wasn't created until 2010/11~
Re:Back end of Meta Threads is built with Python 3.10 with s... by sangnoir on Thursday July 06, 2023 @01:59PM (#36620142)
It turns out calling the app "Threads by Instagram" is not just a branding gimmick. The Instagram backend was always Python/Django since before the acquisition.
Re:Back end of Meta Threads is built with Python 3.10 with s... by mrweasel on Thursday July 06, 2023 @02:48PM (#36620877)
That's pretty interesting, I wonder if that means that it's build by a team at Instagram, and not Facebook. I'd assume so.

I get that Facebook is still a huge success, but I do find it telling that they opted to put Threads under Instagram, rather than Facebook.

Re:Back end of Meta Threads is built with Python 3.10 with s... by jadtz on Thursday July 06, 2023 @03:55PM (#36621870)
I think its pretty obvious they went with Instagram branding, as Facebook branding has been tarnished for a while.
Re:Back end of Meta Threads is built with Python 3.10 with s... by Solvency on Thursday July 06, 2023 @05:33PM (#36623385)
I'm confused.

It's Facebook by Meta. Instagram by Meta. Why isn't it Threads by Meta?

Re:Back end of Meta Threads is built with Python 3.10 with s... by epolanski on Thursday July 06, 2023 @06:26PM (#36624073)
Tied to ig account.
Re:Back end of Meta Threads is built with Python 3.10 with s... by mrweasel on Friday July 07, 2023 @03:42AM (#36628499)
Threads by Instagram by Meta ... TIM for short.
Re:Back end of Meta Threads is built with Python 3.10 with s... by goykasi on Thursday July 06, 2023 @02:04PM (#36620223)
The web codebase was once written in PHP, but they moved away from that a decade ago.
Re:Back end of Meta Threads is built with Python 3.10 with s... by rafark on Thursday July 06, 2023 @02:12PM (#36620366)
It’s still very similar to php. Same syntax, same execution model. If you look at some hack snippets you would think it’s php (because it mostly is).

Switching from hack to php and viceversa should be extremely easy.

That being said, they chose python because Instagram is written in python, they are probably using a lot of existing libraries.

Re:Back end of Meta Threads is built with Python 3.10 with s... by goykasi on Thursday July 06, 2023 @02:18PM (#36620448)
That wouldn't even make sense. They created hack/hhvm to scale and optimize the platform and codebase. Taking a step backwards and refactoring (hack != php now) would be a horrible idea.
Re:Back end of Meta Threads is built with Python 3.10 with s... by coding123 on Thursday July 06, 2023 @01:08PM (#36619226)
Whether it's in C++ or Rust or Python, almost all of any slowness would be from database waiting anyway.
Re:Back end of Meta Threads is built with Python 3.10 with s... by patrec on Thursday July 06, 2023 @02:50PM (#36620918)
It wouldn't. Databases are fast, python is slow.
Re:Back end of Meta Threads is built with Python 3.10 with s... by patrec on Thursday July 06, 2023 @03:27PM (#36621473)
Re:Back end of Meta Threads is built with Python 3.10 with s... by jerrygenser on Thursday July 06, 2023 @10:19PM (#36626201)
Network is slow. So you are waiting on the db for most of a request lifecycle.
Re:Back end of Meta Threads is built with Python 3.10 with s... by pjmlp on Friday July 07, 2023 @03:51AM (#36628567)
That depends on how much work is done in stored procedures instead of wasting network traffic and client CPU cycles to process the results.
Re:Back end of Meta Threads is built with Python 3.10 with s... by patrec on Friday July 07, 2023 @04:26AM (#36628849)
Network latency within an AWS AZ is <1ms and throughput is in the GB/s range.

What percentage of python webapps do you think are hitting this as their latency and throughput limit?

(Assuming effective DB use of course, i.e. not doing dozens of DB roundtrips to server a single result or getting megabytes of data and filtering on the client etc.)

Re:Back end of Meta Threads is built with Python 3.10 with s... by chaoz_ on Thursday July 20, 2023 @07:09AM (#36798958)
True... When I measured something similar in a large python app, the biggest chunk of time went into python object serialization/deserialization.
Re:Back end of Meta Threads is built with Python 3.10 with s... by DeathArrow on Thursday July 06, 2023 @03:13PM (#36621278)
Not really. Look at Techempower web benchmarks.
Re:Back end of Meta Threads is built with Python 3.10 with s... by reissbaker on Thursday July 06, 2023 @06:00PM (#36623719)
I worked at IG on a previous iteration of Threads, with some of the engineers who wrote the current Threads app. It's Django!

(Heavily modded, run on a custom Python JIT, and using an extremely custom FB-developed database, also used for IG and FB.)

It's Django because IG was originally written in Django back in the day. FB's general approach to scaling is keep the interface generally similar, and slowly replace things behind the scenes as necessary — rather than doing big rewrites. It's seemed to work pretty well.

Ultimately the language used for the web server isn't a huge deal compared to the performance of the database, for these kinds of massive social apps. Plus, well, they do have the custom JIT — but that's very new, and when I first joined IG in 2019, we were running vanilla Python in production.

Re:Back end of Meta Threads is built with Python 3.10 with s... by taopai on Thursday July 06, 2023 @06:18PM (#36623982)
Thank you, awesome answer! HN comunity is awesome.

Thanks also to every other answer I received for my question, I appreciated all of them.

Re:Back end of Meta Threads is built with Python 3.10 with s... by kleton on Thursday July 06, 2023 @07:06PM (#36624540)
To answer the first, because I am no longer bound by nda.

Why Django? Because that's what it originally was. Same with YouTube frontend btw. The apps just grew and grew.