Skip to content

davidbacisin/golang-http-connections

Repository files navigation

golang-http-connections

This sample application tests various configurations of the built-in net/http Go HTTP client to explore how these settings impact performance. See my blog post for a discussion of the project and its results.

Requirements

Running the examples

To run the examples, start in the project root.

Create the following directories to mount Docker volumes for the monitoring stack:

mkdir container/data container/data/grafana container/data/prometheus

Then run docker compose up. This launches two containers:

  1. An nginx container to act as the target server. The application will bombard this server with requests. The container provisions a self-signed certificate for HTTPS. The root endpoint returns a hard-coded response to minimize server latency.
  2. An OTEL LGTM container that runs Loki, Grafana, Tempo, and Prometheus, with an OpenTelemetry collector on ports 4317 and 4318. This allows us to collect and view metrics, logs, and traces through a Grafana dashboard at http://localhost:3000/.

Wait a few moments until the OTEL LGTM container says something like, "The OpenTelemetry collector and the Grafana LGTM stack are up and running."

Back in a console, launch the application with the desired example:

go run . <example-id>

where <example-id> is one of 1.1, 1.2, 1.3, 2.1, 2.2, or 2.3. This should print something like Starting Example 2.1: default HTTP/2 client stage 0 to the console. At the start of each stage, a new message is printed. Examples 1.x use HTTP/1.1, while examples 2.x use HTTP/2.

In a web browser, navigate to http://localhost:3000/ and select the "Golang HTTP Connections" dashboard. Now we can monitor our application as it runs.

Contributing

Have a question? Start a discussion in the GitHub Discussions tab.

Found an issue? Check if someone else has filed a similar issue in the GitHub project. If not, file a new one.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published