Skip to content

Instantly share code, notes, and snippets.

View Windsooon's full-sized avatar

Windson yang Windsooon

View GitHub Profile

Idea behind it

I choose Golang to implement the API for two reasons. First, this is a challenge, it will be boring if I keep using my old stack. Second, Golang makes writing a concurrent program easily which is what the requirements ask for.

1. The API must be able to handle high throughput (~1k requests per second).
2. The API should also be able to recover and restart if it unexpectedly crashes.
3. Assume that the API will be running on a small machine with 1 CPU and 512MB of RAM.

For No.1 and No.3, we need to use 1 CPU and 512MB of RAM to handle ~1k requests per second. Therefore, asynchronous I/O would be the best choice. Golang has goroutine which is a perfect fit for this situation. To support restart, we can use Supervisord to monitor the current Go web server, I didn't implement this part because it's more related to configuration than system design (I used it before, feel free to ask me questions for it). To support recovery, for instance,

@Windsooon
Windsooon / leetcode_retag.md
Last active April 23, 2024 03:59
Retag most popular Leetcode problems

osjobs

海外兔

website