How I built an app with 500,000 users in 5 days on a $100 server

The guy who reached 1 million users in 5 days by making a chat app for Pokémon GO fans.

.. The article states that Zarra had a hard time paying for the servers that were necessary to host 1M active users. He never thought to get this many users. He built this app as an MVP, caring about scalability later. He built it to fail.

..  I built image recognition software to automatically check if an uploaded image is Pokémon GO-related, and resizing tools for uploaded images. We run this whole setup on one medium Google Cloud server of $100/month, plus (cheap) Google Cloud Storage for the storage of images. Yes, $100. And it performs well.

..  A database should query only on one index at a time, which is impossible with these geospatial queries.

..  I separate the snaps into a few different collections: all snaps, most liked snaps, newest snaps, newest valid snaps and so forth. Whenever a snap gets added, liked or marked as abuse, the code checks if it (still) belongs to one of those collections and acts accordingly. This way the code can query from prepared collections instead of running complicated queries on one huge pile of mess. It’s simply separating data logically into some simple buckets.

.. How much extra time did I spent on all of this? Maybe 2 to 3 hours. Why I did this in the first place? Because that’s just the way I set things up. I assume my apps will be successful. There’s no point in building an app assuming it won’t be successful.

..  I bake minimum viable scalability principles into my app.

.. At one point last weekend, our server’s 4 NodeJS processes were running at 90% CPU each, which is unacceptable to me for 800–1000 concurrent users. I realized that it had to be Mongoose doing things with my fetched data. Apparently I simply had to enable Mongoose’s “lean()” function to get plain JSON objects instead of magical Mongoose objects. After that change, the NodeJS processes dropped to around 5–10% CPU usage. Just the simple logic of knowing what your code actually does is very important. It reduced the load by 90%.

 

2nd Quadrent: Postgres Scalability

Whatever the requirements, 2ndQuadrant will produce an effective solution that considers both factors, and is aligned with the needs of your business. With a staff of performance experts including Gregory Smith, author of the book “PostgreSQL high performance”, and scalability experts including Hannu Krosing, who engineered a database architecture while at Skype to address their unparalleled PostgreSQL scalability issues, you will be in good hands.

Why Uber Engineering Switched from Postgres to MySQL

When we updated the birth year for al-Khwārizmī, we didn’t actually change his primary key, nor did we change his first and last name. However, these indexes still must be updated with the creation of a new row tuple in the database for the row record. For tables with a large number of secondary indexes, these superfluous steps can cause enormous inefficiencies. For instance, if we have a table with a dozen indexes defined on it, an update to a field that is only covered by a single index must be propagated into all 12 indexes to reflect the ctid for the new row.

.. This write amplification issue naturally translates into the replication layer as well

.. In cases where Postgres replication happens purely within a single data center, the replication bandwidth may not be a problem.

.. However, the verbosity of the Postgres replication protocol can still cause an overwhelming amount of data for a database that uses a lot of indexes.