Sobes.tech
Senior

Tell us about the transition from synchronous to asynchronous architecture: why did you make the transition, how did you identify the problem?

sobes.tech AI

Answer from AI

Transitioning from synchronous to asynchronous architecture usually occurs due to issues with performance and scalability. In my experience, it looked like this:

  • Problem identification: A system with synchronous calls started experiencing delays and blocking as the load increased. Users complained about long response times, and monitoring showed high thread utilization and waiting for responses from external services.

  • Cause: Synchronous calls block the thread until a response is received, limiting the number of requests that can be processed simultaneously.

  • Solution: Moving critical parts of the system to asynchronous processing using goroutines and channels in Go. This allowed not to block threads, handle more requests in parallel, and improve responsiveness.

Example of a simple asynchronous call in Go:

func fetchData(ch chan<- string) {
    // simulate a long operation
    time.Sleep(2 * time.Second)
    ch <- "data"
}

func main() {
    ch := make(chan string)
    go fetchData(ch) // asynchronous call

    fmt.Println("Waiting for data...")
    data := <-ch // receive result
    fmt.Println("Received:", data)
}

Thus, transitioning to an asynchronous architecture helped improve system efficiency and scalability.

Tell us about the transition from synchronous to… - sobes.tech