Exercise 4: Building Web Services

Let’s test our understanding by attempting this challenge.

We'll cover the following

Let’s practice what we’ve learned so far in the following exercise. The solution to this exercise will be provided in the next lesson.

Problem

Implement a simple version of ab(1) using goroutines and channels. ab(1) is an Apache HTTP server benchmarking tool.

Please implement these essential functionalities in your solution:

  • Concurrency Control (-c flag): The code allows you to control the concurrency level (the number of multiple requests made at a time) using the -c flag.

  • Request Count (-n flag): It also allows you to specify the number of requests to perform using the -n flag.

  • HTTP Request: The code initiates HTTP GET requests to the provided URL, similar to what ab does.

  • Request Timing: The code measures the time taken for the tests and calculates the requests per second, which is printed as an output.

To run the server side of the ab(1) utility, open a new terminal window and copy and paste the following command in the terminal:

Get hands-on with 1400+ tech skills courses.