- 6.1 About Ethernet
- 6.2 About Hubs, Switches, and Routers
- 6.3 About TCP/IP
- 6.4 About Packets
- 6.5 About Remote Procedure Calls (RPCs)
- 6.6 Slop
- 6.7 Observing Network Traffic
- 6.8 Sample RPC Message Definition
- 6.9 Sample Logging Design
- 6.10 Sample Client-Server System Using RPCs
- 6.11 Sample Server Program
- 6.12 Spinlocks
- 6.13 Sample Client Program
- 6.14 Measuring One Sample Client-Server RPC
- 6.15 Postprocessing RPC Logs
- 6.16 Observations
- 6.17 Summary
- Exercises
6.10 Sample Client-Server System Using RPCs
The supplied server4.cc and client4.cc implement a sample RPC system with logging. In addition, the supplied dumplogfile4.cc turns binary logs into JSON-formatted ASCII so you can see what they contain and so that they can be displayed easily.
The service provided by these programs is an in-memory key-value store (a simple database). The server program accepts RPCs that read or write key-value pairs in RAM, while the client sends such requests. The server-implemented methods are
Ping(data), returns a copy of data with no key-value action
Write(key, value), remembers the pair
Read(key), returns value
Chksum(key), returns an eight-byte checksum of the value
Delete(key), removes key and its value
Stats(), returns some statistics on server usage
Reset(), erases all key-value pairs
Quit(), stops the server and all its threads
This pair of programs should allow you to get into trouble in myriad ways. Sending a burst of 100 values of 1MB each will saturate a sample server’s 1Gb/sec Ethernet for at least a second. Doing two such actions independently between different machines should overload a sample four-port switch. Sending a burst of 100,000 one-byte values will saturate CPUs quite nicely and also clog up the logging system. Overlapping a heavy-duty burst with some more modest work will likely interfere with the modest work.