Changing Databases 5 Times in 48 Hours Boosted Our Launch to 35,000 Views
Published: 2024-05-06 15:39:12

The way this story begins is about as wacky as its title. I started [Integrated Reasoning](https://integrated-reasoning.com/) in 2021 to find out what would happen if [arbitrary precision](https://docs.amd.com/r/en-US/ug1399-vitis-hls/Overview-of-Arbitrary-Precision-Integer-Data-Types) integers could be used when solving [knapsack problems](https://en.wikipedia.org/wiki/Knapsack_problem) (e.g. 9, 33, and 65 bit registers). My thinking was that a flexible word size would make [pseudo-polynomial time algorithms](https://en.wikipedia.org/wiki/Pseudo-polynomial_time#Knapsack_problem) for solving knapsack problems more efficient. In short, it does help, but the largest gains come from [pipelining](https://www.xilinx.com/developer/articles/task-level-parallelism-and-pipelining-in-hls.html).



Fast-forward to mid-April 2024. We’d just started developing [IRX](https://irx.app), an optimization-as-a-service platform, to serve as the interface to Integrated Reasoning’s hardware accelerated solvers. We planned a MVP that essentially moved the experience of running open-source solvers like [HiGHS](https://github.com/ERGO-Code/HiGHS) from the command line into the browser. The selling point being that these processes can take months or longer to complete, and not having to wrangle them would help our users focus on optimization instead of the infrastructure required to run optimization.

Pushing logs in real-time from AWS to the browser was something I’d never done before. I figured it was roughly similar to the problem of [streaming text from an LLM](https://vercel.com/docs/recipes/streaming-from-llm), something I’d never done before either, which has seen tons of recent development. On one hand, real-time log events might be overkill for an MVP. On the other hand, rendering logs in real-time looks beautiful and would help us provide a user experience that’s as smooth as the command line. We went for it.


![irx.app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5ncdab8cecwrfidgv5o.png)

Our initial plan was to use [Prisma Pulse](https://www.prisma.io/docs/pulse/what-is-pulse) to subscribe to Postgres writes within an edge function that sent each line of stdout from [HiGHS](https://github.com/ERGO-Code/HiGHS), [CBC](https://github.com/coin-or/Cbc), and [SCIP](https://github.com/scipopt/scip) to the browser using [Vercel streaming responses](https://vercel.com/docs/functions/streaming). Other than its complexity, there were two major problems with this plan. Finding a managed Postgres instance that had the right combination of [table replication functionality](https://www.prisma.io/docs/pulse/database-setup/general-database-instructions) to satisfy the requirements of both Pulse and our backend was non-trivial, resulting in the absurdity that is the first half of this article’s title. The cascade of events that stemmed from changing Postgres providers five times in two days is still mind-blowing to me.


![Ant Wilson on Twitter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/42o4f7nsoane5mzl3bap.png)


The domino effect began when Long ([@beertocode](https://x.com/beertocode)) from Supabase reached out with a challenge. He explained that he wants to give new people building with Supabase an extra push. If we build and launch with Supabase within two weeks, they will use their supa-huge following on socials to make the launch a big one. Challenge accepted, and challenge it was.

Social media opportunity is not usually part of the equation when evaluating database options. However, our launch goal was to gather as much user feedback as possible, so it was a factor we couldn’t ignore. Knowing almost nothing about Supabase’s product, I took an afternoon to read through all of their documentation. By that evening I had a completely different, much simpler, mental model for how to build IRX.

Supabase’s [anonymous sign-in](https://supabase.com/docs/guides/auth/auth-anonymous) feature coupled with [row level security](https://supabase.com/docs/guides/auth/row-level-security) meant that people could use IRX on launch day without having to go through a registration process. We’re talking zero barrier to entry, which is something I didn’t even think was possible in the seemingly never ending cycle of “create another account and reset your password” that is life in 2024.

Anonymous sign-in proved extremely valuable to us by making it possible for nearly three hundred people to try solving mixed-integer programs with IRX on launch day — even if they had no idea what IRX was and were just playing around. We got incredible feedback from a wider variety of backgrounds than I’d have ever imagined.


![IRX Traffic](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h0en2wbnzudxv7wfsbn9.png)



The second of the two problems with our approach to real-time log streaming didn’t present itself until after we’d implemented the feature. Prisma Pulse has a limit of at most 20 concurrent subscriptions per table. This limit wasn’t obvious until a resource leak consumed our entire connection quota instantaneously. Capping out at 20 concurrent users would not have made for a good launch and time was really ticking.


![IRX Launch Timer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7banl0soa2fm39kcwqdu.png)



We were still debugging streaming when Long Tweeted us at the three hour mark 😅.   Fortunately by this point I’d read everything there is to read about Supabase, including their [quota table](https://supabase.com/docs/guides/realtime/quotas) for [realtime events](https://supabase.com/docs/guides/realtime), which supports 10,000 concurrent clients out of the box. Making the switch was easy, largely thanks to Supabase’s TypeScript [type generation](https://supabase.com/docs/reference/cli/supabase-gen-types-typescript). 

Other than some [back pressure](https://sdk.vercel.ai/docs/advanced/backpressure) issues, we managed to ship real-time log streaming for three solvers running simultaneously on potentially different spot instances.


![IRX Infrastructure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b1lgl316idyd9vcprnz8.png)

![IRX Solver Infrastructure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tv7730xmmhcmn1rqcfgh.png)

(IRX internal infrastructure diagrams by [@baykovr](https://twitter.com/baykovr))

Long put it best:

![Long on Twitter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1s50siph4hz53iqtpn5r.png)


What’s really crazy is that I signed up for Resend because of their Supabase integration. Their founder [@zenorocha](https://x.com/zenorocha) blew up [our Twitter](https://twitter.com/IntegrateReason/) a few days before the launch, adding another 16,000 views to our launch week traffic with a single tweet.


![Zeno Rocha on Twitter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/juruto1h7g5m32eum8ho.png)


Here’s my sketch of IRX’s infrastructure on the day of the launch:

![IRX Launch Day Infrastructure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a263k49npgp2p22ane1i.png)


We freaking launched. Thank you for the challenge Supabase!


![Supabase on Twitter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5j5fqeqyfolulnf1ctrb.png)