Porting a high-load Node API to Java with AI, in three prompts

TL;DR - I took the “1M req/s” challenge built in Node (node-1m-rps) and asked the AI to port it to Java. Here’s the prompt, ready to paste, and how I got to java-1m-rps with Java 21 and Spring Boot 4 by giving context in three rounds instead of one giant prompt.


The challenge

The repo agile8118/node-1m-rps, which goes with the video “Handling 1 Million Requests per Second”, has a Node API with Express, Fastify or Cpeak, Redis (standalone or cluster), Postgres and the option to run as a cluster with PM2. The idea is to handle high load using Redis as a cache, Postgres for persistence and multiple processes to scale. The challenge I gave the AI was to bring that same architecture to Java.

The prompt

You can paste it into Cursor, Claude Code or any agent that can create a project and run commands. If you want Kotlin or another stack, just change the text.

I want a Java project that replicates the logic and architecture of the Node.js project "Handling 1 Million Requests per Second": https://github.com/agile8118/node-1m-rps

Goals:
- HTTP API that handles high load (target: support 1M+ req/s in a benchmark scenario).
- Redis cache (standalone and, if possible, cluster).
- Postgres persistence; same data model as the reference project (e.g. codes/benchmark table).
- Option to run in cluster mode (multiple JVMs or workers) for horizontal scaling.

Requirements:
- Use a lightweight web framework suited for high performance (e.g. Vert.x, Micronaut, Spring WebFlux or similar).
- Configuration via environment variables (e.g. REDIS_CLUSTER, PG_CONNECT, ports).
- README with: how to run locally, how to start Redis and Postgres, how to run the benchmark (e.g. wrk or JMeter).
- Keep the same "story" as the Node project: same data flow (request → cache? → Postgres → response), DB seed and, if it makes sense, script to migrate data from Postgres to Redis.

Docker is not mandatory; local Redis and Postgres instructions are fine. The code should be minimal and to the point, without unnecessary layers.

If all you want is a skeleton that hits the RPS target in a controlled environment, say so in the prompt. The AI usually comes back with a Maven or Gradle project, a Redis client, a Postgres driver, a reactive HTTP server, endpoints mirroring the Node ones, configuration and a README explaining how to start everything and run the benchmark.

Why Java

The original is Node. Moving it to Java forces the AI into another ecosystem, with a different concurrency model (threads and NIO instead of an event loop), and makes it choose a stack, like which framework and which Redis client. For Kotlin the same prompt works by swapping the language name.

How I built java-1m-rps

I used Java 21 and Spring Boot 4. The prompt above generated the skeleton. Then I pinned the stack (Spring Boot instead of Vert.x or Micronaut), moved configuration to environment variables (REDIS_CLUSTER, PG_CONNECT) and adjusted the README with steps to run locally and benchmark. The architecture is the same as the Node one: Redis as cache, Postgres as the source of truth, and a request only hits the database on a cache miss.

What took work

Parity with Node. The original project has a seed, a Postgres-to-Redis migration and Redis cluster support. In Java, every script and every environment variable needed an equivalent. The AI built the structure, but I got the connections (Postgres pool and Redis cluster mode) right by hand, reading the docs and what the Node code did.

Performance from the start. The target is 1M+ req/s, and a traditional Spring MVC setup with blocking I/O is unlikely to get anywhere close. In the second prompt I made it clear I wanted a reactive stack (WebFlux or similar) and a non-blocking Redis client. The AI switched to WebFlux with Lettuce and the project got on the right track.

Configuration. Between REDIS_CLUSTER, PG_CONNECT, ports and seeds, there was a lot of it. The first skeleton came with everything hardcoded. I asked for “everything via environment variables, nothing hardcoded” and the AI refactored to an application.yml that reads from the environment.

Where the AI got it right and where it didn’t

It got the structure right (Maven, packages, dependencies), the basic flow (controller → service → Redis/Postgres) and the first README. It got configuration details wrong more often, like dependency versions and the Spring Data Redis properties for cluster mode. It also got the seed and migration scripts wrong: that logic lives in the Node code, it didn’t have that code in context, and it made up a generic seed. When I passed the repo link and later pasted snippets of express.js and utils.js into the chat, the behavior got much closer. It’s good at skeletons and patterns, and weak at reproducing scripts and config that aren’t in context.

The three prompts

  1. First: goal, Node link and requirements as bullet points (API, Redis, Postgres, env, README, same flow). I didn’t mention Spring and let the AI suggest.
  2. Second: “Use Spring Boot 4 and Java 21. Reactive stack (WebFlux) and a non-blocking Redis client. All configuration via environment variables.” That fixed stack and config in one go.
  3. Third: I pasted Node snippets (routes, Redis usage, seed format) and asked it to align the behavior with that code. It adjusted the endpoints and the cache flow.

In the end I had the project running, configured through the environment and with a README you could actually follow. The fine-tuning (Postgres pool, Redis timeout, benchmark numbers) I did by hand. Giving context in layers, first the goal, then stack and config, finally the reference code, worked much better than one huge prompt or a bunch of scattered questions.

flowchart LR
  P1[Prompt 1: goal + Node link] --> P2[Prompt 2: stack + config]
  P2 --> P3[Prompt 3: Node snippets]
  P3 --> Projeto[java-1m-rps]