Scalable Code Ideas

Posted on December 02, 2018

I listened to the Function podcast with Anil Dash about a week ago. They discussed the technical challenges of enabling an edit button on Twitter.

And, when you think about it. It’s actually a really hard engineering feat. How can you update all push notifications, emails, feeds, mentions, quote retweets, etc after a user changes a status. You really do have a huge challenge simply to enable the proper display of data everywhere after someone edits something.

At work this week, I started writing all of our core logic with this in mind.

If a functionality became remarkably successful, and we needed to say send 500,000 emails per month. How could we write this so that it’d have minimal impact on the load times of our other services?

Additionally, how could we reasonably collect all access logs, bugs, and processed data in a way that was easy to proactively prevent users from experiencing issues.

It turns out it’s not that much more work to engineer solutions with this in mind.

Some starting points:

  • Use linters for front end code (Eslint + Airbnb’s super strict rules)
  • Focus on accessible HTML. It really helps mobile/touch devices
  • Use strict database Models and structures
  • Use automatic logging with an easily queryable interface to detect abnormalities
  • Use a bug tracking software like Bugsnag
  • Is the code strictly typed?
  • Keep asking yourself every hour:

    • How will this function perform if it was called 6000/day?
    • How fast will this api respond if the request load was 10x what we’re expecting?

It’s always easy to throw bigger servers at the problem later on. Or to try and cut out some css/js later if your frontend code is the issue. But, I find myself moving towards better more stable architecture without “overcoding” the solution.

But, I’ve found that considering how your interface and application will perform at a massive scale to be a good way to stretch yourself as a developer.