Implement simulation with one server

Assignment Help Python Programming
Reference no: EM132192486

Assignment ­ Data Structures

Overview

This week's assignment will focus on using one of the data structures from our reading, the Queue. In this week's reading, there was a discussion about writing a program to simulate a printer and its print queue. The simulation would determine when print tasks would be generated, placed them on the printer's queue to eventually be processed by the printer.

This week, we will do something similar. We will write a network simulator to simulate how network requests are processed by a single web server, and a group of web servers behind a load balancer. We will see how the average wait time, or latency, is related to the server processing rate.

Useful Reminders

1. Read the assignment over a few times. At least twice. It always helps to have a clear picture of the overall assignment when understanding how to build a solution.

2. Think about the problem for a while, and even try writing or drawing a solution using pencil and paper or a whiteboard.

3. Before submitting the assignment, review the "Functional Requirements" section and make sure you hit all the points. This will not guarantee a perfect score, however.

Background

What exactly do we mean by request? In this case, a request is simply some user requesting a file from a web server, via a web browser. For example, when you go to www.google.com in your browser, you are making a network request to the web server hosting google.com. This request gets processed and eventually, the results are sent back to your browser to be displayed.

In this assignment, we will look at how we can simulate this process, representing the server as a queue of requests that need to be processed. In the printer example, the printer can print x number of pages per second. In our case, each request will have its own ‘processing time', which is the amount of time that is needed for the server to process this request. Also, in the real world, a server can process more than one request at a time, since servers typically have more than one CPU. However, just like the printer simulation, we can assume for now that the server only processes on request at a time.

In essence, this assignment is very similar in structure to the printing simulation. Therefore, it is highly recommended to read over the printer simulation section again. This biggest difference between this and the printing simulation is that we will not be generating requests at random, but reading them from a file. This will help keep results consistent and easily testable.

Part I ­ Implement Simulation with One Server

To help outline a solution, you will have a Server class and a Request class. This are akin to the Printer and Task class in the reading. You will need to update these classes to represent the problem at hand.

The file that is used for input will be a CSV file in the following format (an example file can be located here TODO):

7, /images/test.gif, 1
7, /images/header.jpg, 1
8, /home, 2

So, the first line represents a request that came in for the /images/test.gif file at the 7th second of the simulation, and will take 1 second to process. This is an important point: each request tells you which second of the simulation its being generated for. This is unlike the printer simulation, where this was done randomly. You need to update the Request class accordingly. Your main() function should read this file in to get the list of requests being made, and to instantiate your Request objects. This means that you do not need an equivalent function for newPrintTask().

You will also need to implement the simulateOneServer() function, which should take in the input filename. The simulateOneServer() function is responsible for printing out the average wait time for a request (i.e., how long, on average, did a request stay in the server queue before being processed). The simulate function should return this average.

Your main function should accept only one parameter, ­­file, which points to the file to read for request inputs. This main() function should call your simulateOneServer() function. Make sure to put all this code in a file called simulation.py.

Part II ­ Extending the SImulation

The simulation should now be extended to include what is known as a load­balancer. In the real world, typically we have more than on server handling requests.

Update the main() function to take another parameter, ­­servers, which is an integer representing the number of servers. If the parameter is not there, you should run simulateOneServer(); otherwise, you should run your new code in simulateManyServers(), passing in the number of servers to simulate. This new function will be responsible for maintaining a queue for each server, and sending requests to these many servers in a round­robin fashion. For example, if you have two servers, then the first request goes to the first server, the second request to the second server, the third request goes to the first server, etc. The simulateManyServers() function should still return the average latency for the requests.

Part III ­ Results

After running both simulations, what are the results do you see? How does each simulation differ in its average latency?

Verified Expert

In this assignment,I developed the application using python code.In this application I wrote the basic code for the access file.Here I have written function for read csv file .Here i have also written code read the record and perform the split data and search the record and I have also written code for other operation as per client requirement

Reference no: EM132192486

Questions Cloud

Closed system in an organization : What is the difference between an open system and a closed system in an organization?
Engage in employee empowerment : Yahoo caused itself trouble when it decided to not engage in employee empowerment.
What are the arguments for appointing judges : Should judges be elected or appointed? What are the arguments for electing judges? What are the arguments for appointing judges?
What are the main causes of environmental degradation : What are the main causes of environmental degradation in developing countries? Explain each of those causes and their effect on sustainable economic development
Implement simulation with one server : After running both simulations, what are the results do you see? How does each simulation differ in its average latency - simulate function should return
Briefly describe the importance of growing urban slums : Critically and briefly describe the importance of growing urban slums with its pros and cons in the context of real world economic development in major cities.
Did your decision to structure the job in fashion contribute : Did your decision to structure the job in this fashion contribute to this result or did you simply have employees who were not up to the challenge?
What was eventually determined to be the cause : Write a paper that critically analyzes the response to your chosen disaster.
Debts can be avoided by bankruptcy : Which of following debts can be avoided by bankruptcy? Which of the following is true of mortgage?

Reviews

len2192486

12/12/2018 11:47:56 PM

This week’s assignment will focus on using one of the data structures from our reading, the Queue. In this week’s reading, there was a discussion about writing a program to simulate a printer and its print queue. The simulation would determine when print tasks would be generated, placed them on the printer’s queue to eventually be processed by the printer. This week, we will do something similar. We will write a network simulator to simulate how network requests are processed by a single web server, and a group of web servers behind a load balancer. We will see how the average wait time, or latency, is related to the server processing rate.

Write a Review

Python Programming Questions & Answers

  The program should allow the student

The program should allow the student to enter the answer. If the answer is correct, a message of congratulations should be displayed. If the answer is incorrect, a message showing the correct answer should be displayed.

  Write a program to simulate the grocery store

You have been asked to write a program to simulate the grocery store as it checks out customers. YOU ARE REQURED TO USE A QUEUE TO SOLVE THE PROBLEM.

  Recogntition of handwritten mathematical expressions

Recogntition of Handwritten Mathematical Expressions - You have the source code but some part of the code has some errors. So you need to correct these errors

  Assignment brief you are tasked with improving the code for

assignment brief you are tasked with improving the code for the haunted house game. please read the associated hand-out

  Write a function that will print the details of a player

CE151 ASSIGNMENT - Write a function which takes a string argument, and creates and returns a tuple containing details of the player specified by the string

  What is the distance of shortest path for the traveler

CS1081 Homework Assignment. A traveler is departing from point A toward point B with a constraint: What is the distance of shortest path for the traveler

  Write a python script for the ice cream ordering system

ICT702 : Write a Python script for the ice cream ordering system.Your program must store the prices of the individual items (cones, scoop flavours and toppings)

  Implement key exchange using the diffie-hellman algorithm

Implement key exchange using the Diffie-Hellman algorithm, when peer- to-peer connections are made between bots and achieve confidentiality through encryption of the client-server commu- nications with an appropriate block or stream cipher.

  Describe the original data for the city you are observing

Describe the original data for the city you are observing. Regression Analysis Hypothesis testing. Explain the hypothesis and the result by graph.

  Planning the tropical airlines program

CP1401 - Fundamentals of Problem Solving and Programming - Jamescook University - Use what you have learned in class, including simple functions, selection

  Implement a function that takes a filename as input

FIT1008 - Implement a function that takes a filename as input and reads it into an instance of the class you implemented on Task 2. For each line in the file

  Write two versions of a factorial function

You need to write a few functions in Python. Write two versions of a factorial function.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd