Hacker News new | ask | show | jobs
by xtracto 13 days ago
I recently built a small nextjs/node application that basically makes like $50 usd monthly. Initially built as a PoC, I wanted to place it in a vps so that I didn't have to maintain it in my home laptop, and also because I wanted to move it to a Europe location for better business performance [im in mexico and latency is high].

Thing is, the TS app weighted around 4GB overall and took 2s to do its thing. [A backend process, an http api and a static website generator].

I needed to decrease the size and increase performance dramatically,to be able to put it in a 2GB 2vcpu instance, which costs $12 monthly. Otherwise it would eat the profit.

Claude ported it to Rust, in around 2 days total. And it went down to 1.5Gb max, and 1/10 of the CPU usage. Now it sits in the aws europe zone making money.

2 comments

What exactly is it doing during these 2 seconds? What did it stop doing for those 2 seconds to become whatever it is now? Did Claude use a different (more fitting) design, architecture and data structures perhaps? Did Claude also write the initial version?
Processing input from a websocket, and then doing some calculationsand http requests [which need low latency, hence the Europe server].

Apparently a lot of the node baggage was due to Garbage Collection, which Rust doesn't need. Also, immediately transforming incoming JSON to binary data helped.

Yes, to both: claude wrote the initial architecture, under my guidance. As I mentioned it was a PoC, so the first pass was "quick and dirty". Shit the original web server was React [which i didn't count for the comparison because barebones node can serve static pages as well.

It has been a cool experiment which started as a crazy idea, but now as I said gives me some spare change. I just SSH tunnel every day or two and load the web page to see how things are going.

Was it Claude that made the terrible choice of using nextjs in the first place?