CS 111, Spring 2013 Scribe Notes
Lecture 16. 5/28/2013
Zijun Xue
Lecture 16. 5/28/2013
Zijun Xue
Robustness,parallelism and NFS
Table of Contents
Abstraction
Abstraction can be implemented via several ways. One way is use the virtualization.
Example r = chmod("/etc/password",0644)
- Above is actural a syscall.
- Scaling is an issue.
- Bus can be bottleneck(or locks)
Abstraction via RPC(remote procedure call)
- Looks like a funtional call
- scale better
Differences between RPC and function calls(or even syscalls)
- caller and callee don't share memories(+)
- no call by reference(-)
- hard modularity -- even better than syscalls (+)
- caller and callee may use different architectures, like X86,ARM etc.(+-)
- only call by value--large value may be slow.
- different data representations(big endian vs. little endian)
solutions for different architectures:uniform network representation
- marshalling(serialization)
- caller marshalls
- callee unmarshalls
- XML, JSON, etc.
difference between ordinary app and distributed system
For common app, we have a little glue code to connect the library and the code. The library and the code are in the same machine.
RPC failure modes are different
- callee can't trash caller's data
- message can get lost
- messages can get corrupted.
- network might be down(or slow)
- server might be down(or slow)
- TCP:resend
- UDP:app deals with it
glue code should do
- if message corrupted
- if no response
- fail, return error -- at most once RPC
- exactly one RPC -- hard to implement
- resend
- retry, keep trying, until success-- at least once RPC
- works better for transaction
RPC example
- HTTP protocol
- SOAP(Simple Access Object Protocol)
- X-windos system
- send "GET / HTTP/1.0\r\n"
- receive "HTTP/1.1 200 OK\r\n content-length: 10423"
performance problem about RPC
coalese requests: 4 set pixel requests from X windos program
Asychronous calls is used. It splits calls into two parts
- request
- notification
How to improve the performance of RPC
- HTTP pipelining
- Change API to send bigger data chunks
- Cache recent answer to requests
- Prefetch answers
- requests identify themselves
- responses specify request to receive
- possible problem is that response come back out of order
- dependent requests may be problematic: create file xyz and change permission of xyz
- collaboration to server
- stale cache problem is very common when you deal with RPC program.
- only for read-only actions
NFS protocol
MKDIR(dirfh,name,attr)-->fh+attrs
name: no "/" allowed
LOOKUP(dirfh, name)--->fh+attr
CREATE(dirth,name,attr)---->fh+attr
REMOVE(dirth,name)---->status
READ look like Unix, NFS was designed for Unix
WRITE CIFS(designed for Windows)
NFS design goal
- clients should survive server crashes nicely
- NFS by design doesn't have read/write consistency.
- It does have open/close consistency through fsync and fdatasync.
- stateless server(can be slow)
- we can solve this problem: use flash on server to store pending requests.(NVRAM)
- Writes don't wait for the server to respond,if a write fail, a later "close" will fail.
- Can use "fsync"(write all data) and "fdatasync"(write all data to disk) to make sure data is written
In order to keep consistency, we add a serial# for file handler.
- file handler = inode# + device# + serial#