Adding concurrency to the server
In this section, we will learn how to add concurrency to the HTTP server. First, let us see why we need to add concurrency to our server. In order to understand that better, let’s add another route to the Responder module, which performs a long-running operation. We can simulate that here by just sleeping for five seconds:
lib/test_goldcrest_http_server/responder.exs
defmodule TestGoldcrestHTTPServer.Responder do
  import Goldcrest.HTTPServer.ResponderHelpers
  def resp(_req, method, path) do
    cond do
      # ..
      method == :GET && path == "/long-operation" ->
        # sleep for 5 seconds
        :timer.sleep(5000)
        http_response("Hello World LONG LONG")
    ...