Sobes.tech
Senior

How is 180K RPS and p99 latency <170ms possible?.

sobes.tech AI

Answer from AI

Achieving 180K RPS (requests per second) with p99 latency <170ms requires a comprehensive approach:

  • Code optimization: Using efficient algorithms and data structures, minimizing locks and synchronization costs.
  • Parallelism and asynchrony: In Go, this involves goroutines and channels that allow processing multiple requests simultaneously.
  • Load balancing: Distributing requests among multiple service instances.
  • Caching: Using caches to reduce database load and speed up responses.
  • Profiling and monitoring: Constant analysis of bottlenecks and optimization of hot paths.

Example of a simple HTTP server in Go capable of handling many requests:

package main

import (
    "fmt"
    "net/http"
)

func handler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "OK")
}

func main() {
    http.HandleFunc("/", handler)
    http.ListenAndServe(":8080", nil)
}

For real load, a more complex architecture with load balancers, caches, and optimizations is required.