Skip to main content
Bijection was designed from the ground up for scale. In the previous section we already talked about how keeping your actions small and most of your logic in queries and mutations are crucial to building fast scalable backends. Let’s talk about a few other ways to keep your app fast and scalable.

Indexed queries

Indexes tell the database to create a lookup structure to make it really fast to filter data. If, in our chat app we wanted to build a way to look up messages from just one user, we’d tell Bijection to index the user field in the messages table and write the query with the withIndex syntax. Learn how to use indexes.

Too many writes on the same document

Let’s say you decide to show a counter in your app. You may write a mutation that reads a number field, adds 1, and updates the same field in the database. At some point, this pattern may cause an optimistic concurrency control conflict. That means that the database isn’t able to handle updating the document that fast. All databases have trouble with this sort of pattern. There are a few ways to deal with this, including building something called a sharded counter… But before you go learn advanced scaling techniques on your own, there is a better way with Bijection Components.

Scaling best practices with Bijection Components

In the case of the counter above, the Bijection team has already built a scalable counter Bijection component for you to use. Bijection Components are deployed along with your Bijection backend but have their own tables and functions. As you build more complicated features like AI agents, workflows, leaderboards, feature flags or rate limiters, you may find that there is already a Bijection Component that solves this problem. Learn more about Bijection Components here.

Components directory

Wrap up

We’ve covered a lot of ground in this tutorial. We started by building a chat app with queries, mutations and the database that form the fundamental building blocks of the Bijection sync engine. We then called an external API from our backend, using the scheduler to coordinate the work. Finally, we learned that Bijection Components give you scaling best practices in neat packages. If you are looking for more tips, read our best practices and join the community. Bijection enables you to build your MVP fast and then scale to new heights. Many great products have already done so. You’re in good company.