Building a Tech Stack that Scales

sculpture-1694728_1280
"...this is it; we built this great thing and we totally messed it up" - Kevin Systrom, Instagram Founder

Building a robust, distributed stack from day one is overkill, but you should already be thinking about how you'll scale, how much load your current system can handle, and how long it will take to scale if your app/service blows up overnight. Instagram's founders Kevin Systrom and Mike Krieger learned this firsthand when they launched their photo app in late 2010.In an interview published to NPR's How I Built This back in September, the founders of Instagram reflected on the early days of the app and how it was a miracle they survived the launch.

"To be clear, there is no reason we should have succeeded. The server was down every other hour."

The entire backend of Instagram was running on a single self-hosted server. Luckily, at the time, mobile networks weren't known for being reliable, so users often blamed the "network failures" on their mobile provider rather than the actual cause - connections timing out due to an overloaded server unable to accept any new requests. The initial feeling of success seeing all of the new users coming online quickly fleeted when they realized they didn't build a system with scale in mind.

"It was nothing more exhilarating seeing all of those people stream in, and nothing more crushing than seeing people posting on Twitter or on their blogs, 'Ugh, another startup that doesn't know how to scale'."

So what's the Solution?

This may just be the Java speaking in me, but the more abstract you can build your stack, the easier it will be to swap components out. By abstracting service interaction through interfaces, you can build services that can interact agnostically between say a local filesystem and a distributed, "cloud" database.[caption id="attachment_573" align="alignnone" width="1024"]

interace_illustration

Interfacing provides a layer of abstraction[/caption]When the time comes to scale, you can easily swap out the filesystem for something more robust like a remote database as long as it implements the interface. This can be hard to visualize without a concrete example sometimes, so let's take a look at Cloud Campaign's stack.[caption id="attachment_647" align="alignnone" width="3208"]

cc-tech-stack

Cloud Campaign Tech Stack[/caption]At first glance, it looks like the system is comprised of many different servers and storage providers, but in reality there is only a single computing server running in production. By separating the functionality into micro-services, we can simply pull the services apart and put them on their own machines when the time comes. But until the system is hitting upper constraints, all of the micro-services can run together on a single machine.This goes back to the idea of using interfaces to simplify service interactions. Right now it may just be a method call, tomorrow it might be RPC, next week it may be API. Regardless of the protocol, the data being transferred between the services is the same and the client call is the same since it's just interacting with an interface.Looking back at Cloud Campaign's setup, Portal, Notification, and Trigger service are all running on the same server, bundled in a single Jar. The message bus is an ActiveMq broker running locally, and Zookeeper is also running as a local service.Building the system this way takes a bit longer initially, but will save a lot of time when you need to grow. And saves a ton of money instead of just scaling from day 1.

Considerations as your Stack Changes

tech_stack.png

Each time you make a change to your stack, you should revaluate to adjust and optimize to the changes. Two major areas to focus on are:

  • Means of communication (method call, RPC, API, persistent TCP, etc...)
  • Caching / Network Costs

I think the means of communication will be fairly obvious, and in most cases will be dictated by how you configure your system. But, caching is often overlooked and is a crucial part of getting any system to scale. If you had two services that were once on the same machine, but now are running separately, adding a layer of cache can drastically decrease latency and increase scalability.If you expand by adding an additional layer to the stack, add in-memory, local cache such as Guava or something similar, while if you're scaling horizontally you should consider adding a distributed cache such as Hazelcast or Memcached.

Cloud Campaign

smb_month_ad_small.png

If you're interested in learning more about Cloud Campaign's tech stack or want to grow your startup by automating your social media campaign, fill out the subscription box with your email below.Thanks for taking the time to read. Would love to hear your thoughts below, or list what you're working on so other people can check it out.- Ryan

Entrepreneurship

Affiliate Success: Guide to Marketing Assets

In this post, we'll show you how to use Cloud Campaign marketing assets to bolster your affiliate campaign.

Read more
December 5, 2023
SMM Tips

Master Holiday Posting on Social Media 

We’ll be exploring the ins and outs of posting holiday and observational content, delving into the benefits, potential pitfalls, and practical steps to make this holiday season one of cheer and social media success. 

Read more
December 7, 2023
SMM Tips

January Social Media Holidays 2024

Start your content calendars off with a bang this year by taking advantage of some awesome social media holidays occurring this month. You'll find holidays, examples, and free Canva templates here.

Read more
December 5, 2023
SMM Tips

Growing Your Social Media Manager Skills

With a fast-moving field such as social media, staying up-to-date on new platform features, tools, and phrases is important to your relevance online and your efficiency in your role. Here's how to grow your SMM skills.

Read more
November 20, 2023
SMM Tips

The Most Efficient Social Media Posting Workflow For SMMs In 2023

In this post, we'll show you how to set up your content publishing workflow, scheduling automation, and content approval workflow to help you shave hours off your SMM work week.

Read more
November 14, 2023
AI Tips

Content Writing In The Era of AI

Content writing in the era of AI has changed, but for better or worse? We dive into content writing in the era of AI to explore its benefits and pitfalls in this post.

Read more
November 9, 2023