-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Arjun Dattatray Bhavsar edited this page May 18, 2020
·
10 revisions
Welcome to the Memcached-Lite wiki!
- The Memcached- lite is the Server that will provide a stable environment to save and retrieve data.
- It will save the (Key, Value) pair and maintain the same repository for all the clients connected to the server.
- The server communicates with clients using TCP as well as UDP connections.
- This assignment uses a TCP connection to communicate with the server.
- It only allows the key-value pair to set and get Commands.
- There are multiple parameters for both the tags
- Set – It Has Key, Byte Size, Valid time, and the final value as parameters
- Get – It has Key as a parameter which will provide the value for that particular key if available.
This assignment is focused on client-server communication and stable data storage. Server.java is dependent on the client ‘ThreadHandler.java’ class for its execution. Server Functionality: -
- Server Creates the Connection using Server Socket using one of the ports.
- Then it makes itself available for the clients to connect.
- Once the connection comes to the same port, and the address of the server connection gets established.
- Then the server assigns the client socket to the Socket object which is used for communication with clients.
- The Sockets contain input and output streams that are used to read and write respectively to the stream and send it to the client.
- Then socket, Input Stream, and output stream have been provided to thread class.
- Thread class takes the string and performs Set, Get operations on the input strings
- And Saves the data to the CSV file.
- The server as running in the while loop becomes available for new client requests maintaining the concurrency, as we have client 1 in the running state.
- Hence By this way server creates a successful concurrent environment to handle multiple clients at a time.
- Here if the server gets disconnected, it still maintains the data it has earlier. For which it reads the data once the server loads again, also maintains a stable storage environment.
- It will give Handle all the client requests in a concurrent manner.
- Then go to the src directory and run the following commands to start the server.
- The client has very fewer things to worry about as compared to the server.
- To establish the Connection clients generate the socket and provide the Address of the server and the port number to connect with.
- If the server is available to connect with then and then only the connection gets setup.
- Otherwise, it will give an exception as n server is available to connect.
- To read the data from the server continuously the client runs in the while loop.
- The client writes the commands in the output stream and retrieves the response of the server in the input stream.
- It can send the multiple commands to the server and retrieves the response.
- Multiple such clients can connect to the server at once and run the commands in parallel.
- The Concurrency is maintained using multithreading.
- It’s the java file which will be responsible for generating the client-server interactive session.
- Client1 accepts the input from the user and sends it to the server and gives a response of the server in the terminal.
- It will run one command at a time.
To Run:
Go to src folder using Command- cd MemcachedClientServer/src/
Run Following Command to Compile and Run.
- To test the scaling testCase1.java is used.
- It’s the client that is used to show the scaling capacity of the server.
- It will make 1000 set commands in one go
- The server will respond with stored or not stored.
- The following is the result of the same.
- It takes 33.4 seconds to run for 1000 commands to run
- It’s the test case to run 1000 get commands in one flow on the single client.
- It gives the values for all the searched key in the format below.
- Its client which runs 500 set and 500 get commands.
1 Have tried connecting 10 clients to the server once – 2) And I am able get the concurrent environment in all 10 clients.