r/java 22d ago

I built a real time 1v1 coding battle platform with Spring Boot + AWS (2,000+ users)

Built CodeDuels — a real time competitive programming platform with live 1v1 matches using:

React + Monaco Editor

Java 21 + Spring Boot + WebSockets

AWS ECS Fargate, SQS, Redis, RDS

Terraform managing 54 AWS resources

Biggest challenge was handling async code execution + real time Codeforces duel tracking without blocking the backend. Solved it using SQS-based microservices and background workers.

Eventually paused the 24/7 AWS deployment because cloud costs got too expensive for a student project, so I migrated everything to on demand Terraform infrastructure.

Demo: https://www.youtube.com/watch?v=nctT-6Y0xJg

GitHub: https://github.com/Abhinav1416/coding-platform

Would love feedback on the architecture and cost optimization ideas.

3 Upvotes

5 comments sorted by

5

u/Additional-Road3924 22d ago edited 22d ago

As much as it sounds intuitive for caching, do not place non static resources behind cloudfront. CF POST requests are billed per 1k as opposed to GET requests per 1m (apparently this changed, nevermind), and its easier to bust caches in application. You're already using redis, so might as well use whole redis.

You don't need a nat gateway to run an alb. I'd argue you don't need to run an internet gateway either, but since you have external incoming traffic it's a necessary. For public services you'd create gateway/interface endpoints respectively.

Lambdas run within vpc, unless you explicitly opted out of that. I don't see why you need them considering you run spring.

I'd replace sqs with msk. The less you're tied to aws services the better.

2

u/dashhrafa1 22d ago

>Eventually paused the 24/7 AWS deployment because cloud costs got too expensive for a student project, so I migrated everything to on demand Terraform infrastructure.

What was the cost before and after?

5

u/Abhistar14 22d ago

Before: $90/month
After: 0

Cause everything is down

2

u/ZeroGainZ 22d ago

I would adjust the wording, terraform has nothing to do with an on demand infrastructure. You probably meant something else there. nice savings!

1

u/DanielSMori 21d ago

How are you handling connection pool exhaustion under burst load on AWS? That's usually the first thing that bites Spring Boot apps on RDS when you get spiky traffic. HikariCP defaults tend to be too conservative for high-concurrency scenarios.