Run Stateful Logic Anywhere with Rivet Engine
As developers, we often run into the same problem: how do you execute long-running, stateful logic without getting bogged down by infrastructure? Whether it's for game servers, background jobs, or real-time simulations, managing state across different environments is a pain.
That's the itch Rivet Engine is trying to scratch. It's a new open-source project that lets you write stateful code that can run seamlessly across different platforms—be it your local machine, a cloud function, or a dedicated game server—without you having to rethink your architecture for each one.
What It Does
In simple terms, Rivet Engine is a framework for writing and running stateful services. You write your logic in TypeScript (or JavaScript), and Rivet handles the hard parts: persisting state, handling concurrency, and networking. It provides a runtime that abstracts away the underlying infrastructure, so your code behaves the same way whether it's running on a serverless platform or a dedicated machine.
The core idea is that you define "lobbies" or services that maintain a persistent state. Clients can then connect to these lobbies to interact with the running logic. Rivet manages the entire lifecycle, from spinning up the service to tearing it down when it's no longer needed.
Why It's Cool
The magic of Rivet is in its flexibility. You're not locked into a specific cloud provider or deployment model. Write your game server logic once, and it can run on AWS Lambda, a Kubernetes cluster, or even your local machine during development. This is huge for testing and development speed.
It's also built with real-time, multiplayer scenarios in mind. The built-in networking and state synchronization mean you can focus on your application's behavior instead of the plumbing. The project comes from the gaming world (Rivet is a game infrastructure company), so it's battle-tested for scenarios that require low latency and real-time interaction.
From an implementation standpoint, it's cleverly designed. It uses a combination of protobuf for efficient networking and provides a clean, type-safe API for developers. The state management is persistent but also fast, using an in-memory cache that's backed by durable storage.
How to Try It
The best way to get a feel for Rivet Engine is to dive into the code. The GitHub repository is well-documented with several examples to get you started.
Head over to the Rivet Engine GitHub repo and clone it. You'll find a quickstart
guide in the README that will walk you through setting up a simple project.
The basic steps are:
- Install the Rivet CLI.
- Initialize a new project.
- Write your stateful logic in a
lobby
file. - Use the CLI to run it locally or deploy it.
The repo includes examples for different use cases, like a simple chat server or a game state manager, which are perfect for understanding the core concepts.
Final Thoughts
Rivet Engine feels like a tool that solves a very specific but common architectural problem. If you've ever found yourself wrestling with how to make a serverless function stateful or how to keep your local dev environment in sync with your cloud deployment, this project is worth a look.
It won't be the right tool for every job—if you're just building a simple CRUD app, it's probably overkill. But for developers working on real-time applications, game servers, or complex background processing, Rivet Engine could be a game-changer. It lets you focus on writing your application's logic instead of managing your application's state across different environments.
Check out the repo, star it if you like the approach, and maybe even contribute. It's a solid open-source project with a clear vision.
Follow us for more cool projects: @githubprojects