cs5012009-CHAPTER 2 Architectures PROBLEMS

5,114 views
Skip to first unread message

Hongfei Yan

unread,
Mar 6, 2009, 8:56:50 AM3/6/09
to cs50...@googlegroups.com
1. Q: If a client and a server are placed far apart, we may see network latency dominating overall performance. How can we tackle this problem?

2. Q: What is a three-tiered client-server architecture?

3. Q: What is the difference between a vertical distribution and a horizontal distribution?

4. Q: Consider a chain of processes P1 , P2 , ..., P n implementing a multitiered  client-server architecture. Process P i is client of process P i+1 , and P i will  return a reply to P i−1 only after receiving a reply from P i+1 . What are the main  problems with this organization when taking a look at the request-reply performance at process P1 ?

5. Q: In a structured overlay network, messages are routed according to the  topology of the overlay. What is an important disadvantage of this approach?

6. Q: Consider the CAN network from Fig. 2-0. How would you route a message  from the node with coordinates (0.2,0.3) to the one with coordinates (0.9,0.6)?

7. Q: Considering that a node in CAN knows the coordinates of its immediate  neighbors, a reasonable routing policy would be to forward a message to the
   closest node toward the destination. How good is this policy?

8. Q: Consider an unstructured overlay network in which each node randomly  chooses c neighbors. If P and Q are both neighbors of R, what is the probabil ity that they are also neighbors of each other?

10. Q: Not every node in a peer-to-peer network should become superpeer. What  are reasonable requirements that a superpeer should meet?










Lilei

unread,
Mar 11, 2009, 9:35:39 AM3/11/09
to cs501pku
第六题怎么讲?CAN里面节点之间到底是怎么样的拓扑结构?只要是相邻区域就可以吗?书没看明白 :(

Hongfei Yan

unread,
Mar 12, 2009, 1:06:05 AM3/12/09
to cs50...@googlegroups.com
相邻区域也有距离呀,找个距离公式算算,或者看看讲CAN文章的里面是如何计算的。

wzhang

unread,
Mar 12, 2009, 10:39:50 AM3/12/09
to cs501pku
ppt 里的一段内容:
When a TCP write call returns, can you discard the data?
int important_data[100];
while (some_condition) {
// Call below overwrites array.
prep_important_data(important_data);
write(connfd, important_data,
100*sizeof(int));
}
If you do discard immediately, what bad things might happen?

write 返回是不是表示数据已传出呢? 直接 discard 会有问题吗?

Hongfei Yan

unread,
Mar 12, 2009, 11:19:55 AM3/12/09
to cs50...@googlegroups.com
不能直接discard.

1) man 2 write,可以看到
NOTES
       A  successful  return  from  write()  does not make any guarantee that data has been committed to disk.  In fact, on some buggy implementations, it does not even guarantee that space has successfully been reserved for the data.  The  only  way  to be sure is to call fsync(2) after you are done writing all your data.


2) 写socket程序,为了保证写出去,可以等一阵,看这个例子
可以参考这个链接,http://www.linuxjournal.com/article/2333
这个程序,http://net.pku.edu.cn/~course/cs501/2009/code/socket.t/srv.cpp

    /*
     * when connection is closed, there is a need to linger to ensure all data is
     * transmitted, so turn this on also
     */
    {
        struct linger linger = { 0 };

        linger.l_onoff = 1;
        linger.l_linger = 30;
        status = setsockopt(serverSocket, SOL_SOCKET, SO_LINGER, (const char *) &linger, sizeof(linger));

        if (-1 == status) {
            perror("setsockopt(...,SO_LINGER,...)");

Hongfei Yan

unread,
Mar 20, 2009, 5:32:55 AM3/20/09
to cs50...@googlegroups.com
1. Q: If a client and a server are placed far apart, we may see network latency dominating overall performance. How can we tackle this problem?
A: It really depends on how the client is organized. It may be possible to divide the client-side code into smaller parts that can run separately. In that case, when one part is waiting for the server to respond, we can schedule another part.  Alternatively, we may be able to rearrange the client so that it can do other work work after having sent a request to the server. This last solution effectively replaces the synchronous client-server communication with asynchronous one-way communication.


2. Q: What is a three-tiered client-server architecture?
A: A three-tiered client-server architecture consists of three logical layers, where each layer is, in principle, implemented at separate machine. The highest layer consists of a client user interface, the middle layer contains the actual application, and the the lowest layer implements the data that are being used.


3. Q: What is the difference between a vertical distribution and a horizontal distribution?
A: Vertical distribution refers to the distribution of the different layers in a multitiered architectures across multiple machines.  In principle, each layer is implemented on a different machine. Horizontal distribution deals with the distribution of a single layer across multiple machines, such as distributing a single database.


4. Q: Consider a chain of processes P1 , P2 , ..., P n implementing a multitiered  client-server architecture. Process P i is client of process P i+1 , and P i will  return a reply to P i−1 only after receiving a reply from P i+1 . What are the main  problems with this organization when taking a look at the request-reply performance at process P1 ?
A: Performance can be expected to be bad for large n. The problem is that each communication between two successive layers is, in principle, between two different machines. consequently, the performance between P1 and P2 may also be determined by n-2 request-replay interactions between the other layers. Another problem is that if one machine in the chain performs badly or is even temporarily unreachable, then this will immediately degrade the performance at the highest level.


5. Q: In a structured overlay network, messages are routed according to the  topology of the overlay. What is an important disadvantage of this approach?
A: The problem is that we are dealing only with logical paths. It may very well be the case that two nodes A and B which are neighbors in the overlay network are physically placed far apart. As a consequence, the logically short path between A and B may require routing a message along a very long path in the underlying physical network.

6. Q: Consider the CAN network from Fig. 2-8. How would you route a message  from the node with coordinates (0.2,0.3) to the one with coordinates (0.9,0.6)?
A: There are several possiblities, but if we want to follow the shortest path according to a Euclidean distance, we should follow the route (0.2,0.3) -> (0.6,0.7) -> (0.9,0.6), which has a distance of 0.882. The alternative route 90.2,0.3) -> (0.7,0.2) -> (0.9,0.6) has a distance of 0.957.


7. Q: Considering that a node in CAN knows the coordinates of its immediate  neighbors, a reasonable routing policy would be to forward a message to the  closest node toward the destination. How good is this policy?
A: In our example from the previous question, it can already be seen that it need not lead to the best route. If node (0.2,0.3) follows this policy for the message destined for node (0.9,0.6), it would send it off to node (0.7,0.2).

8. Q: Consider an unstructured overlay network in which each node randomly  chooses c neighbours. If P and Q are both neighbours of R, what is the probability that they are also neighbours of each other?
A: Consider a network of N nodes. If each node chooses c neighbours at random, then the probability that P will choose Q, or Q chooses P is roughly 2c/(N-1).


10. Q: Not every node in a peer-to-peer network should become superpeer. What  are reasonable requirements that a superpeer should meet?
A: In the first place, the node should be highly available, as many other nodes rely on it. Also, it should have enough capacity to process requests. Most important perhaps is that fat that it can be trusted to do its job well.
Reply all
Reply to author
Forward
0 new messages