Skip to content

Commit d79f8e0

Browse files
committed
Doc: overhaul PocketBase comparison.
1 parent 3729f70 commit d79f8e0

File tree

5 files changed

+143
-76
lines changed

5 files changed

+143
-76
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ TrailBase is free software under the terms of the [OSL-3.0](LICENSE).
161161
We chose this license over more popular, similar copyleft licenses such as
162162
AGPLv3 due to its narrower definition of derivative work that only covers
163163
modifications to TrailBase itself. This is similar to GPL's classpath or LGPL's
164-
linkage exception allowing the use of TrailBase as a framework without
165-
inflicting licensing requirements on original work layered on top.
164+
linkage exception allowing the use of TrailBase as a framework and JS runtime
165+
without inflicting licensing requirements on your original work.
166166
That said, we ain't lawyers. The author of the license provides a more thorough
167167
[explanation](https://rosenlaw.com/OSL3.0-explained.htm). If you have any
168168
concerns or advice for us, please reach out.

docs/src/content/docs/comparison/pocketbase.mdx

Lines changed: 133 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,92 +3,156 @@ title: PocketBase
33
description: Comparing TrailBase & PocketBase.
44
---
55

6-
Firstly, PocketBase is amazing! It based the trail for single-executable,
7-
SQLite application bases, is incredibly easy-to-use, and a polished
8-
experience. Gani, the person behind it, is a mad scientist.
6+
import { Aside } from "@astrojs/starlight/components";
7+
import GettingTrailBase from "../getting-started/_getting_trailbase.md";
98

10-
At the surface-level there are a lot of similarities between PocketBase and
11-
TrailBase. In this comparison, we'll dive a little deeper and have a closer
12-
look at the technical as well as philosophical differences between the two.
9+
Firstly, PocketBase is amazing! It paved the way for single-executable
10+
application bases, is incredibly easy-to-use, and a polished
11+
experience. Gani, the person behind it, is a mad scientist 🙏.
1312

14-
### Goals & Aspirations
13+
From a distance PocketBase and TrailBase are both single-executables providing
14+
almost identical feature sets: REST APIs, realtime updates, authentication, file
15+
storage, JavaScript (JS) runtimes, admin dashboard..., all on top of SQLite.
16+
17+
For the sake of this comparison, we'll dive a little deeper to have a closer
18+
look at their differences both technically and philosophically.
19+
20+
## Goals
1521

1622
TrailBase was born out of admiration for PocketBase trying to move the needle
1723
in a few areas:
1824

19-
- Less abstraction, embracing standards (SQL[^1], JWT, UUID), and untethered access
20-
to SQLite[^2] including features such as recursive CTEs, virtual tables
21-
and vector search.
22-
The goal is to not get in your way and avoid lock-in by bespoke solutions
23-
making it easier adopt TrailBase either fully or as piece-meal as well as
24-
getting rid of it based on your product needs.
25-
- Be just as easy to self-host and be even easier to manage a fleet of
26-
deployments across integration tests, development, and production by separating
27-
data, configuration, and secrets.
28-
- Super-powers through SQLite extensions (regex, GIS, ...) including your own [^3].
29-
- Be lightweight enough to rival plain SQLite performance at least for
25+
- Less abstraction and embracing standards (SQL[^1], ES6 Node-like JS runtime,
26+
JWT, UUID) to not get in your way, avoid lock-in and making it easier to
27+
adopt TrailBase either fully or as piece-meal as well as getting rid of it if
28+
necessary.
29+
- Untethered access to SQLite[^2] including features such as recursive CTEs,
30+
virtual tables and extensions, e.g., providing vector search and geoip out of
31+
the box[^3], unlocking more use-cases and standard solutions to well-known
32+
problems.
33+
- Be lightweight and fast to rival in-process SQLite performance at least for
3034
higher-level languages.
31-
- Be simple and flexible enough to be an attractive alternative to plain SQLite
32-
for serving **and** data analysis use-cases.
33-
34-
### Differences
35-
36-
It's worth noting that PocketBase and TrailBase have a lot in common: they are
37-
both single static binaries providing CRUD plus realtime APIs, JavaScript
38-
runtimes, authentication and file storage on top of SQLite.
39-
That said and for the sake of this article, let's look at some of the
40-
differences and extra features that PocketBase provides:
41-
42-
- PocketBase can also be used as a Go framework, i.e. instead of using the
43-
binary release one can build a custom binary with custom endpoints.
44-
Similarly you can use Rust to do the same with TrailBase.
45-
46-
Likewise, TrailBase has a few nifty tricks up its sleeve:
47-
48-
- Language independent type-safety via JSON Schemas with strict typing
49-
being enforced all the way down to the database level[^4].
50-
- TrailBase's JavaScript runtime supports full ES6, TypeScript transpilation,
51-
and is built on V8 making it [~40x faster](/reference/benchmarks/#javascript-performance).
52-
Supporting ES makes it easier to integrate popular JS frameworks for SSR.
53-
- First-class access to all of SQLite's features and capabilities.
54-
- A simple auth UI.
55-
- Stateless JWT auth-tokens for simple, hermetic authentication in other
56-
backends.
57-
- Efficient and stable cursor-based pagination.
58-
- An admin UI that "works" on small screens and mobile :)
35+
- Be just as easy to self-host with aspirations to be even easier to manage a
36+
fleet of deployments across integration tests, development, and production.
37+
We'd also like to eventually takle replication.
38+
- Be simple, flexible and portable enough to support data analysis use-cases.
39+
Imagine a self-contained data science project that ships an interactive UI
40+
with vector search and custom JS extensions alongside its data.
5941

60-
### Language & Performance
42+
## Differences
6143

62-
Another difference is that PocketBase is written in Go, while TrailBase uses
63-
Rust. Beyond feelings this may matter to you when using them as a "framework"
64-
or modifying the core.
44+
Beyond goals and intentions, let's look at some of the more practical differences:
45+
46+
### Language & Performance
6547

66-
In practice, both languages are speedy options with a rich ecosystem.
67-
That said, Rust's lack of a runtime and lower FFI overhead should make it the
68-
more performant choice.
69-
Measuring we found a significant gap with TrailBase's APIs being roughly
70-
[10x and JS runtime 40x faster](/reference/benchmarks/).
71-
This is the result of SQLite of first-class JS engines being so quick that even
72-
small overheads weight heavily.
48+
PocketBase being written in Go and TrailBase in Rust may be the most instantly
49+
visible difference.
50+
Preference aside, this will likely matter more to folks who want to use
51+
either as a framework rather than the standalone binary or modifying the core.
52+
53+
In practice, both languages are solid, speedy options with rich ecosystems.
54+
Though Rust's lack of a runtime and lower FFI overhead gives it the edge in
55+
terms of performance.
56+
Measuring we found that TrailBase's APIs are roughly [10x faster](/reference/benchmarks/).
57+
This may sound like a lot but is the result of SQLite itself being extremely
58+
fast meaning that even small overheads weigh heavily.
59+
60+
Independently, TrailBase choice of V8 as its JS runtime allows code to run
61+
roughly 40x faster.
62+
63+
### Framework Use
64+
65+
Both PocketBase and TrailBase allow customization using their built-in JS
66+
runtimes. However, some users may want even more control and built their own
67+
binaries using only bits and pieces.
68+
This is what we refer to as library or framework use. For this use-case
69+
language preference and prior experience of you and your team will likely matter
70+
a lot more with PocketBase written in Go and TrailBase in Rust.
71+
72+
Framework use is something PocketBase has allowed for a long time and is really
73+
great at.
74+
TrailBase technically allows it too, but at this point it really feels more
75+
like an afterthought while we focus on the standalone experience.
76+
Expect TrailBase to improve significantly in this area.
77+
78+
### Features
79+
80+
When we look more deeply into the seemingly identical features sets, many and
81+
constantly evolving differences are starting to surface.
82+
In lieu of enumerating them all, let's look at some examples.
83+
84+
Auth is an area where PocketBase's maturity clearly shows: while it uses
85+
simpler session-based auth, as opposed to stateless JWT auth-tokens, it
86+
supports multi-factor auth and a larger set of social OAuth providers.
87+
This is an area where TrailBase needs to improve but maybe stateless tokens is
88+
just what you're after 😅.
89+
90+
Despite being the new kid on the block, TrailBase has a few nifty tricks up its
91+
sleeve:
92+
93+
- Language independent bindings via JSON-schema with strict type-safety
94+
being enforced from the client all the way to the database[^4].
95+
- A more Node-like JS runtime with full ES6 support, built-in TypeScript
96+
transpilation, and V8 performance unlocking more of the JS ecosystem and enabling
97+
[server-side rendering (SSR)](https://github.com/trailbaseio/trailbase/tree/main/examples/collab-clicker-ssr)
98+
with any popular JS framework.
99+
- Untethered access to SQLite with all its features and capabilities.
100+
- A wider set of first-class client libraries beyond JS/TS and Dart, including
101+
C#, Python and Rust.
102+
- Ships with a simple pre-built auth UI to get you started. You can always
103+
graduate to your own.
104+
- Efficient and stable cursor-based pagination as opposed to `OFFSET`.
105+
- An admin UI that "works" on small mobile screens 😅.
106+
107+
### Contributing & Licensing
108+
109+
Both PocketBase and TrailBase are truly open-source: they accept contributions
110+
and are distributed under [OSI-approved](https://opensource.org/licenses) licenses.
111+
PocketBase is distributed under the permissive MIT license, while TrailBase
112+
uses the OSL-3.0 copyleft license.
113+
We chose this license over more popular, similar copyleft licenses such as
114+
AGPLv3 due to its narrower definition of derivative work that only covers
115+
modifications to TrailBase itself. This is similar to GPL's classpath or LGPL's
116+
linkage exception allowing the use of TrailBase as a framework and JS runtime
117+
without inflicting licensing requirements on your original work.
118+
119+
## Final Words
120+
121+
PocketBase is great and both PocketBase and TrailBase are constantly evolving
122+
making it hard to give clear guidance on which to pick when.
123+
If you can afford the luxury, I'd recommend to give them both a quick spin.
124+
After all they're both incredibly quick and easy to deploy.
125+
126+
In the end, if you're looking for mileage or framework use-cases you're likely
127+
better off with PocketBase.
128+
Otherwise it may be worth giving TrailBase a closer look, especially when
129+
flexibility and performance matter.
130+
131+
<Aside type="note" title="Getting TrailBase">
132+
<GettingTrailBase />
133+
</Aside>
73134

74135
<div class="h-[30px]" />
75136

76137
---
77138

78-
[^1]: Maybe more in line with SupaBase's philosophy. We suspect that PocketBase
79-
relies on schema metadata by construction requiring alterations to be
80-
mediated through PocketBase APIs to stay in sync.
139+
[^1]:
140+
We believe that SQL a ubiquitous evergreen technology, which in of itself
141+
is already a high-level abstraction for efficient, unified cross-database
142+
access.
143+
ORMs, on the other hand, often look great in examples but many fall apart
144+
for more complex tasks. They're certainly bespoke, non-transferable
145+
knowledge, and lead to vendor lock-in.
81146

82-
[^2]: We believe that SQL a ubiquitous evergreen technology, which in of itself
83-
is already a high-level abstraction for efficient, unified cross-database
84-
access.
85-
Even higher-level abstractions, such as ORMs, often look nice for simple
86-
examples but quickly fall flat for more complex ones. They're certainly
87-
bespoke, non-transferable knowledge, and increase vendor lock-in.
147+
[^2]:
148+
Maybe more in line with SupaBase's philosophy. We suspect that PocketBase
149+
relies on schema metadata by construction requiring alterations to be
150+
mediated through PocketBase to keep everything in sync.
88151

89152
[^3]:
90153
All extensions can be built into a small, standalone shared library and
91-
imported by vanilla SQLite avoiding vendor lock-in.
154+
imported by vanilla SQLite to avoid vendor lock-in.
92155

93-
[^4]: SQLite is not strictly typed by default. Instead column types merely a
94-
type affinity for value conversions.
156+
[^4]:
157+
Note that SQLite is not strictly typed by default. Instead column types
158+
merely a type affinity for value conversions.

docs/src/content/docs/getting-started/_getting_trailbase.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ $ alias trail="docker run \
88
-p 4000:4000 \
99
--mount type=bind,source=$PWD/traildepot,target=/app/traildepot \
1010
trailbase/trailbase /app/trail"
11-
$ mkdir traildepot # pre-create docker bind-mount path
11+
$ mkdir traildepot # pre-create mount point for Docker
12+
$ trail run
1213
```
1314

1415
or compile from [source](https://github.com/trailbaseio/trailbase).

docs/src/content/docs/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ import { Duration100kInsertsChart } from "./reference/_benchmarks/benchmarks.tsx
6969
serve millions of customers from a tiny box.
7070

7171
In terms of JS/TS performance, V8 is roughly
72-
[40x faster](/reference/benchmarks#javascript-performance)
72+
[40x faster](/reference/benchmarks#javascript)
7373
than goja used by PocketBase.
7474
</div>
7575

docs/src/content/docs/reference/benchmarks.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ this test TrailBase can insert 100k records 170 times faster than Payload[^4],
8282
almost 40 times faster than SupaBase[^5], and comfortably 11 times faster
8383
than PocketBase [^1].
8484

85+
### Utilization
86+
8587
The total time of inserting a large batch of data tells only part of the story.
8688
Let's have a look at resource consumption to get an intuition for provisioning
8789
or footprint requirements, i.e. what kind of machine one would need:
@@ -145,7 +147,7 @@ Most of the CPUs seem to be consumed by *supabase-rest*, the API frontend, with
145147
postgres itself hovering at only about 0.7 cores. Also, *supabase-analytics*
146148
definitely seems to be in use.
147149

148-
## Latency and Read Performance
150+
## Read and Write Latency
149151

150152
Let's take a closer look at latency distributions. To keep things manageable
151153
we'll focus on PocketBase and TrailBase, which are architecturally simpler and
@@ -185,7 +187,7 @@ being roughly 3 times slower than p50.
185187
Slower insertions can take north of 100ms. This may be related to GC pauses,
186188
scheduling, or more generally the same CPU variability we observed earlier.
187189

188-
## File System Performance
190+
## File System
189191

190192
File systems play an important role for the performance of storage systems,
191193
we'll therefore take a quick at their impact on SQLite/TrailBase's performance.
@@ -228,7 +230,7 @@ disc space and feature sets. For example, CoW snapshots may or may not be
228230
important to you.
229231

230232

231-
## JavaScript Performance
233+
## JavaScript
232234

233235
The benchmark sets up a custom HTTP endpoint `/fibonacci?n=<N>` using the same
234236
slow recursive Fibonacci

0 commit comments

Comments
 (0)