Question

In: Computer Science

Client must support load-test mode, in this mode, echo client opens a number of concurrent connections,...

Client must support load-test mode, in this mode, echo client opens a number of concurrent connections, sends a predefined message on each connection, waits for echo message back from server, and records time. User should be able to specify total number of messages to be sent concurrently from client.

Here is an example run of new mode

$python advanced_echo.py load_test 1000

Above, should cause client to attempt 1000 connections CONCURRENTLY, send predefined message, wait for echo back and record time it took each of 1000 connections to close.

Output of client should look like:

CON-1: duration: 20ms

CON-2: duration: 19ms

Solutions

Expert Solution

Answer : Given That

Duration of CON-1 is 20ms & Duration of CON-2 is 19ms.

Using Python Code :

# import the required modules

# requests to send http requests
import requests

# time, to measure the response time
import time

# sys, to parse the cli arguments
import sys

# get the number of concurrent connections to be established
n = int(sys.argv[2])

# send request for n times
for i in range(n):
    # get the current time
    start = time.time()
    # send the request and wait for the response
    resp = requests.get('<REQUEST_URL>')
    # get the current time
    end = time.time()
    # get duration
    duration = end - start
    # print message
    print("CON-%s: duration: %sms" % (i+1, round(duration*1000)))

Output :

____________THE END_____________


Related Solutions

Write and test a python program to demonstrate TCP server and client connections. The client sends...
Write and test a python program to demonstrate TCP server and client connections. The client sends a Message containing the 10 float numbers (FloatNumber[]) , and then server replies with a message containing maximum, minimum, and average of these numbers.
provide an example of considerations the disability support provider must have when working with a client...
provide an example of considerations the disability support provider must have when working with a client relating to client's culture
W shape column must support a axial load (DL=500 kips y LL= 300 kips). The element...
W shape column must support a axial load (DL=500 kips y LL= 300 kips). The element is 30 ft length and braced in the y direction at 14 ft from the column base. The end support conditions are (fixed/pinned). Justify the material’s selection. verify slenderness and local buckling and Select the lightest section
code an 8 bit LFSR random number generator in system verilog. Write a test bench, load...
code an 8 bit LFSR random number generator in system verilog. Write a test bench, load the seed 11111111, and generate the first 10 random numbers.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT