The CTO of talks about how he made his site snappy and fast, with Cloudflare Workers, Drizzle and Turso

Japan is a bucket list country for a lot of people — natural sites, a deep rooted culture and world renowned cuisine. Japan has it all. But it's also one of the more difficult countries to use…

Cover image for The CTO of talks about how he made his site snappy and fast, with Cloudflare Workers, Drizzle and Turso

Japan is a bucket list country for a lot of people — natural sites, a deep rooted culture and world renowned cuisine. Japan has it all. But it's also one of the more difficult countries to use existing services on the internet to properly plan a stellar trip to, both due to language barriers and local specifics.

Enter The company leverages deep local domain expertise, providing a thorough understanding of what makes an amazing visitor experience in Japan, to offer a variety of multi day tours personalized to people's groups size and difficulty level. Combining inventory from multiple operators, is able to tailor trips and experiences to any traveler to make their journey unique, all with an easy to use, highly performant user interface.


People want to visit Japan from all over the world, so it is crucial that the site render with extremely low latency from many different places. In the travel and ecommerce industries, wait times are directly correlated to churn and lower conversion rates. One of the pieces of the low latency puzzle is to make sure your software stack is running as close as possible to your users.

“At ‘Trip to Japan', we're on a mission to break world records for shipping fast, and to pull it off, we need to keep things simple and robust. Downtime means deviating from our core task of delivering new value.” — Jökull Solberg, CTO of Trip to Japan

To fulfill their mission of great developer velocity at sub-100ms latency, Solberg looked into a modern stack, composed of Cloudflare Workers, the Drizzle ORM, and Turso Database.

#For functions: Cloudflare Workers

To keep their backend latencies globally low Trip to Japan chose Cloudflare Workers. The Workers platform offers a developer friendly and flexible platform to ship dynamic code close to users. The workerd JavaScript runtime offers a standardized browser-like production environment that is available as a developer runtime as well. Trip to Japan uses the Hono and tRPC libraries to provide its edge web clients with a type-safe way to fetch and store data into the database.

“The Cloudflare Worker platform helps us keep the team size small by taking our code, distributing it across the globe and keeping it running on the workerd runtime — the same we use in development — with great observability and stability. There's no such thing as zero ops and zero latency, but Cloudflare Workers comes close with its hundreds of edge locations and robust code pipeline.“

#Thinking low latencies from the ground up

In the travel sector, one of the major obstacles to achieving low latency is that queries are usually complex. Creating a single response needs to query the database many times. Moreover, the data is provided by third party vendors. For example, you may need to query your own inventory for tours, but third parties for travel and accommodation operators.

Vendor query times are unpredictable, but Trip to Japan didn't want a progress indicator. While the user waits, they may as well go somewhere else and give up. To tackle this, Trip to Japan is using Cloudflare Scheduled Tasks to keep a search index up to date, which then delivers a sub-100ms search UI for almost up-to-date inventory.

#The database: Turso

In an edge architecture, data can be the achilles heel of the application: if data is far from the edge function, at best the latency gains from the edge are nullified. At worst –for complex requests that need to query the database many times — the edge is just making things worse.

The solution is to locate the data close to the application, but that can be an expensive and daunting task. Running a full fledged database in many locations is not trivial to set up. Routing to the right replicas is a source of issue, and the setup quickly becomes very expensive.

To tackle their data access, the team chose Turso, an Edge Database that provides easy and affordable replication across the world. Turso not only massively replicates the data across the world, but also abstracts the locations of the database, making sure that the application is always automatically routed to the closest replica without any configuration change.

“Lots of database vendors talk about buzzwords like ‘serverless' and ‘edge,' but it's rare to find one that walks the walk. Turso is such one, nailing the sub-100ms performance promise by providing replication across strategic locations of your choosing as close to the app code and user as possible. And they back that up with solid client libraries and a client protocol that works with any major edge platform. They also take care of the routing to the closest replica using just one connection string. Once you've picked your locations Turso takes care of the rest.”

#Locally, in addition to the Edge

Turso is built on libSQL, an Open Contribution fork of SQLite. It aims to bring the developer experience of SQLite to the Edge. This allows developers to take advantage of an unmatched local development environment. Solberg highlights that “SQLite is legendary for its simplicity and robustness and now there's a cloud vendor that brings it to the web.

#The Drizzle ORM

As the ORM layer, the code that runs on Cloudflare Workers code relies on Drizzle, a quickly evolving hybrid SQL adapter that provides both a query builder and a succinct ORM to interact with SQL databases, including the Turso Database.

Despite being a relatively new project and sometimes lacking in functionality in comparison to more established players like Prisma,Solberg put his trust in the Drizzle ORM.

For one, he mentions that the feature gap with its competition has been closing fast: in particular, Drizzle has recently launched a migrations suite, both for automatically scaffolding migration scripts but also a “push” command popularized by Prisma for quick schema iteration.

But also, despite being a nascent Open Source project, the Drizzle ORM is quickly securing corporate support. In particular, they list the Turso Database as a Gold Sponsor of their project. Solberg remarks that

“It is reassuring to see that Drizzle and Turso play so well together. We're putting our chips on this combination because they have an amazing operational and developer experience story that plays well with our Edge environment, Cloudflare Workers. Drizzle feels like a query builder/ORM combo, stirring up some good old Django nostalgia, but with a new twist — it's all happening on the edge now.. Things have never been as fast, both for users and our engineering team.”


Trip to Japan has recently launched their site, aggregating experience inventory from hundreds of travel operators across many of Japan's incredible cities and destinations. By combining Cloudflare Workers, Turso Database and the Drizzle ORM, the team at Trip to Japan could ship on schedule, while taking full advantage of what the edge has to offer: low latencies and great experiences to the end user, wherever the users may be.

If you haven't been to Japan yet, perhaps found the language barrier or booking experience intimidating, give them a visit: your Trip to Japan could be only a couple of milliseconds away!