DIY PaaS: serverless real-time with one command

Cover for DIY PaaS: serverless real-time with one command

Translations

If you’re interested in translating or adapting this post, please contact us first.

Maybe this time, you just want to sprinkle a bit of that real-time magic on top of your app: add reactions, comments, or notifications. But once you’ve gotten a taste for it, you’ll come back for more–to grow engagement and boost monetization. It’s important to choose a scalable, maintainable real-time solution now so you’re happy and productive tomorrow. Let’s propose a framework for making the move.

The real-time and collaborative features in Figma, Google Docs, and Notion helped them to rise above their competition. And now people increasingly expect a kind of “real-time-ness” everywhere, both in apps and on the web.

For professional tools, this has had an even bigger effect: the pricing model where a single user is free, and a team is paid by a business has proven its effectiveness. Hence, “teams” is not only the source of growth and engagement, but also the key source of monetization. Teams want to collaborate, and collaboration requires real-time synchronization.

Where problems begin creeping in…

Normally, you start small with real-time: take a ready-made PaaS and plug it in for one particular feature. But it tends to grow.

And then you notice that PaaS bills are out of control.

Or, you may think: how do I ensure security and compliance for that real-time data? You bump into platform limitations and platform risks. Finally, developer productivity may sink when the ready-made solution turns out to be not flexible enough.

The moment of truth always comes sooner than you’d think!

This is why it’s best to consider the alternatives early, and choose your real-time infrastructure carefully.

(Of course, if you’re building with a real-time-first stack like Phoenix/Elixir, you don’t have this problem. 🥂 Cheers! This is for everyone else in the room.)

What are my options?

With that out of the way, let’s think about four choices:

1. First, consider real-time solutions provided by your infrastructure/cloud vendor. If you’re on AWS, you have API Gateway with its Websocket APIs. Cloudflare provides Durable Objects.

The common drawback with these options is that none of them are standardized, so they will only deepen any vendor-lock sorrows, making migration to another cloud provider even harder. You also want to pay attention to pricing models, as billing for those additional services tends to come as a surprise.

2. Next, 3rd-party PaaS are a widely advertised solution you might think about.

But, while high-level solutions like Liveblocks will give you a head start, they’ll later limit your capabilities once the cookie-cutter solution isn’t cutting it. Low-level APIs like Ably and Twilio are tempting, and many companies go with them, but not everyone is ready for the bill that arrives once they’ve hit a certain scale.

3. You could build your own solution. Figma, Shopify, and other big tech companies use home-grown solutions for real-time infrastructures that they support and maintain.

This could be optimal for larger organizations, but not necessarily the best move for small or medium-size businesses. But there’s an even better option.

4. Finally, running your own real-time open source-based service.

You might have heard that it’s not so easy to scale WebSocket infrastructure. In general, this is true. Or, it was true—until recently.

Today, decades of innovation in DevOps and cloud platforms have finally borne fruit: deploying and scaling a server can be as easy as running one command. Especially a server that’s already been tried, tested, and trusted by hundreds of organizations—like AnyCable, Centrifugo and others. This is exactly the case for running AnyCable on Fly.io and other modern clouds.

The benefits of an open source real-time solution

Dedicated solutions, available in open source, like AnyCable, allow you to build your own PaaS in a matter of a few hours, while solving multiple problems:

  • Pay for the gas, not the taxi itself
  • Own all the data and have full control over it (helps security and compliance)
  • Owning the data means you have as much flexibility as you need to build out features
  • It’s open source, so you’re not vendor-locked (even if there’s a lock on the solution, you have the key because it’s open source)
  • Put the progress to work: modern deployment platforms already minimize overhead of running and scaling the service

How AnyCable stacks up

Specifically, with AnyCable, we’ve put 6 years into perfecting developer productivity:

  • It provides proven and tested abstractions, like channels and subscriptions
  • It guarantees delivery and restores messages lost due to connectivity issues
  • Stability: it ensures auto scaling, smooth reconnection on deployment, fallbacks from WebSockets to other transport, and much more
  • It is integrated with the GraphQL ecosystem

All of this ensures that engineers can focus on describing business logic in a clear and maintainable way, without the need to worry about the intricacies of real-time connectivity, WebSockets, or having to write tons of boilerplate code.

Running real-time on your own time

But you probably still think that running your own real-time server is going to give you a major headache. But is it really like that?

Let’s say you’ve got an app built with Next.js, deployed to Vercel. Additionally, you’re using serverless functions, and now you want some real-time in mix. In Vercel’s docs, you’ll find a bunch of PaaS options to do this. But you could also run your own AnyCable real-time server instead!

Here’s what’s needed:

  1. Deploy AnyCable to the cloud of your choice. We suggest Fly.io, where AnyCable will configure itself. You only need to run one command.
  2. In our Vercel app, add one serverless function to connect to AnyCable. Copy the code from here.
  3. That’s it! Now you only need to write our business logic using AnyCable Serverless SDK. And check out the demo application (it’s a chat).

Compare this to the typical steps you’d need to make in order to connect to a PaaS solution, and tell us what you think using the form below. We are ready to consult you on building out any real-time functionality: chats, real-time updates, GPS trackers, collaborative editors, and more.

Real-time knowledge is real-time power

At Evil Martians, we transform growth-stage startups into unicorns, build developer tools, and create open source products. If you’re ready to engage warp drive, give us a shout!

Solve your problems with 1-1 guiding

Tell us about your goals and roadblocks and get actionable advice for your product based on our time-tested experience working with developer-first startups—for free!

Reserve your spot
Launch with Martians

In the same orbit

How can we help you?

Martians at a glance
17
years in business

We transform growth-stage startups into unicorns, build developer tools, and create open source products.

If you prefer email, write to us at surrender@evilmartians.com