> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bijection Tutorial: Scaling your app

> Learn how to scale your Bijection application using indexes, handling write conflicts, and leveraging Bijection Components for best practices.

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.

<div className="center-image" style={{ maxWidth: "560px" }} />

## 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](/database/reading-data/indexes/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](/error#write-conflict-optimistic-concurrency-control). 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](/error#remediation), 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](/components/overview).

## 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](/agents/overview),
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/overview).

<CardGroup cols={1}>
  <Card title="Components directory" />
</CardGroup>

## Wrap up

We've covered a lot of ground in this tutorial. We started by
[building a chat app](/tutorial/overview) with queries, mutations and the
database that form the fundamental building blocks of the Bijection sync engine. We
then called an [external API](/tutorial/actions) from our backend, using the
scheduler to coordinate the work. Finally, we learned that
[Bijection Components](/components/overview) give you scaling best practices in
neat packages.

If you are looking for more tips, read our
[best practices](/understanding/best-practices/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.
