How we successfully handled 2.5x traffic in a week
engineering.khanacademy.org
engineering.khanacademy.org
I mean being able to scale that easily is a great thing, but is there anything worth sharing with the world in their case ?
Khan Academy doesn't have infinite money.
Some companies need to take a much harder look at their spend than others regardless of where you deploy.
There's a reason other non profits like Wikipedia and the Internet Archive run their own hardware, networking, and connectivity to transit providers. And before the "doing that is expensive!" argument comes up, note how expensive having someone else do these things are. Lots of margin built into cloud services.
My contribution is that I am helping with automating video uploads to the team youtube channel, which is allowed to have "Kahn Academy {language}" branding.
Shameless plug: If any google or youtube employees can help me raise our API quota please get in touch!!! :)
Kthxby
There's only really one sensible way to do it, and that's the way it's done.
It's sort of like someone asking how you rebuild the stock carburetor on a 1967 Mustang, and replying "Make an educated guess about the design of youtubes serving infrastructure, and I'm pretty certain you're right." For the vast majority of people, that's no use at all.
A lot of people seem to think of Khan Academy as a bunch of videos. Many have also seen the exercises and articles. Those things are all pretty static (though it gets more complex when you consider how much content there is and how many languages it's localized into).
There's a whole bunch of dynamic behavior around that static content. Keeping track of progress to tell a learner how they're doing, plus to help recommend the next place to go in the content. Reporting on progress to parents and teachers. Letting teachers create assignments and manage their classrooms. Bubbling up information to school districts.
Content pages have discussions and clarifications. There are notifications to tell students about new assignments, for example.
There are connections to tests, like the SAT prep or integration with the MAP test, which involve connecting our accounts with external accounts in order to help students based on those test results.
And a bunch of other stuff that isn't coming to mind right now because I'm just naming things off the top of my head.
Doing all these things across a user base of millions of monthly users can get quite involved.
In the blog post Marta said:
> In the month of April, we served 30 million learners on our platform
How much did it cost to run this whole stack on GCP in April 2020? Was it $150,000? More or less?
I will say that the amount we pay for our infrastructure, especially right now, is reduced by generous support from both Fastly and Google. It still remains a substantial expense after that support.
One final note on cost: we are actively working on a Python to Go transition[1] that will reduce our hosting costs, among other benefits.
To turn it around, why would you ever want someone to not share their experience with the world if they took time to write it down? It's not like you must read it; it doesn't cost you anything to exist. But if someone's experience adds to the library of human knowledge, even a little bit, why would one try to reject that?
The trickier part can be the cost-- which this piece notes will increase roughly linearly with the number of users. If Khan Academy is free, I think this means those who are generous are going to need to keep giving to keep it that way. Let's step up, everyone.
As their blog post says, they weren't unprepared. They had the means to grow and used it. Burning money before that time wasn't necessary.
Disclaimer: I don’t have children, so I have no real world experience with Khan.
We did have quite a bit of usage and awareness among schools already before the shutdowns started. Couple that with there being many options for teaching online… I wouldn't be surprised if a lot of schools just switched to having their teachers attempt to do their normal teaching via Zoom (which sounds really hard to me!). Many schools had contracts of various sorts with other online learning platforms.
Some schools or classes haven't had great follow through rates, which is unfortunate, but educators all over have had to quickly adjust. I suspect that more robust plans will be in place by the fall, given how much uncertainty there is for fall classes. Khan Academy is, at least, an always-free resource that's there for people if they need it.
That 2.5x is starting from a large base, and there's also a lot of activity in online education generally.
This is exactly what is happening in our school district and it is a big failure. That and teachers emailing their lesson plans for parents to print or parents can go to the school and pick up printed packets. We then have the joy of taking photos of the completed work and emailing those back to the teachers.
It is extremely inefficient and I have already informed our school that we will not be doing that if we are stuck in this scenario come fall. We will be using Khan for math and other online learning platforms for LA.
> Khan Academy's increased usage has also increased our hosting costs, and we're a not-for-profit that relies on philanthropic donations from folks like you.
Edit: ah, a case study from Google about Khanacademy. This post was definitely an ad: https://cloud.google.com/customers/khan-academy Another: https://cloudplatform.googleblog.com/2013/08/khan-academy-ru...
- No Rust/Go rewrite
- GC not disabled
- Didn't apply the latest research on k/v storage
Jokes aside, this is the fun parts of hosted software and glad to hear the "things don't have to be so hard" side of things. Hope it continues working out!
They have used Backbone.js [6] and experimented with other programming languages like Kotlin [7].
Read their engineering blog [8] and you will know more and maybe learn a few things.
[1] http://engineering.khanacademy.org/posts/python-refactor-1.h...
[2] http://engineering.khanacademy.org/posts/transaction-safety....
[3] http://engineering.khanacademy.org/posts/upgrade-buttons-lin...
[4] http://engineering.khanacademy.org/posts/goliath.htm
[6] http://engineering.khanacademy.org/posts/upgrade-buttons-lin...
[7] http://engineering.khanacademy.org/posts/kotlin-adoption.htm
And their reason is because their code is currently Python 2. To avoid some manual code refactoring to support Python 3, they shall rewrite in an entirely different language. So they'll train their entire programming staff in Go and task these new inexperienced Go programmers to do a straight port of their code base from one highly opinionated language to a different highly opinionated language.
They've certainly done an excellent job enumerating all of the very lucrative benefits of a Go rewrite, while ignoring or hand-waving away any of the challenges. It all screams version 2 syndrome.
Who knows, maybe this is a great move for them. I’m only going on their blog post about it. But at minimum they've done a poor job communicating how they've looked at this challenge objectively and without rose-tinted glasses.
I've found devs are always trying to over-engineer complex solutions to dead simple problems. Just let Google do it and get some sleep.
https://status.khanacademy.org/
Unfortunate timing for the blog post to reach HN...
Peak was usually when semester end was coming. Currently, daily, we must sustain 2x of that peak, but peaked at 3x of that on the first day "remote schools opened". The everyday traffic is currently like almost 3x it would have been, measuring by requests per second received on frontends.
We were struggling usually at end of semester. Luckily we stated to do some upgrades and optimizations to handle that, just before the lockdown started. In the end, we can now sustain many more times traffic we have. The hardest part wasn't adding more resources (that was a MUST for sure) but it was much more effort to handle stuff that scales vertically (SQL) and some file share issues.
So there were some intermittent issues that were frustrating the users, sometimes bringing whole site down for minutes. (Sometimes is the trickiest part to handle). That includes hunting down expensive queries (not so hard), calling less or more optimal queries, taming SQL plan cache and dealing with some NTFS stuff for file share.
Some of the issues couldn't be solved solely throwing more hardware in.
I'm still puzzled for the file share issue on Windows. Yeah, not so clever to store millions of files in a single folder within NTFS filesystem. We have append-only share, no deletes ever happening. Stuff like timestamps and short paths were disabled, defragmented $mft and the likes, but... every ~24 hours the drive would become sooo painfully slow and inacessible. Some access denied errors get thrown, etc. And it continues for some minutes. Maybe 15. Sometimes more. But between that ~15min period it works, so it's like a wave with some period. But the thing is, outside of this window, the file share works very good (with all those millions of files within a folder). They were never deleted and we didn't need to enumerate - just fetch file by file.
No, Antivirus wasn't at fault, no backup system wasn't messing around. Is there stuff NTFS may do under the hood on SSD drives? I'm aware there is a TRIM process, but as I understand it has to deal when the stuff is being deleted from the SSD?
We moved to rotating disks (!) and split those files across few folders and got rid of those issues. But still, 1 folder contains way more files you would hear anyone saying is healthy on NTFS.
Seven years ago I was at a medical conference in Portland, Oregon with a panel of "experts" discussing the security and accessibility of medical record systems and wearable devices. There was a principal engineer from Intel on the panel. When someone asked about the cloud, this tall, lanky, long-bearded man with a thick accent stood up and said:
"The cloud? (chuckles) What is the cloud? Where is the cloud? Is it over here? (Points to a table) Is it over there? (points to another table). The cloud is a joke, man. It's a complete joke."
EDIT: added an anecdote for SEO. :)
You can store stuff in workers KV (sessions, images, complete static sites, etc) even interact with their global cache with an API.
We (Khan Academy) are certainly not at Facebook's scale, but we do run a site with a lot of dynamic behavior and millions of monthly users. If we had our own bare metal in data centers, we either would have been way overprovisioned or would have been scrambling to keep up.