Danh mục

Advanced PHP Programming- P9

Số trang: 50      Loại file: pdf      Dung lượng: 515.82 KB      Lượt xem: 10      Lượt tải: 0    
10.10.2023

Xem trước 5 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Tham khảo tài liệu advanced php programming- p9, công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả
Nội dung trích xuất từ tài liệu:
Advanced PHP Programming- P9378 Chapter 15 Building a Distributed Environment Client X Client Y Client X get a fresh Client Y gets a stale copy of Joes page copy of Joes page Server A Server B Newly Older Cache Cached Figure 15.6 Stale cache data resulting in inconsistent cluster behavior. Centralized Caches One of the easiest and most common techniques for guaranteeing cache consistency is to use a centralized cache solution. If all participants use the same set of cache files, most of the worries regarding distributed caching disappear (basically because the caching is no longer completely distributed—just the machines performing it are). Network file shares are an ideal tool for implementing a centralized file cache. On Unix systems the standard tool for doing this is NFS. NFS is a good choice for this application for two main reasons: n NFS servers and client software are bundled with essentially every modern Unix system. n Newer Unix systems supply reliable file-locking mechanisms over NFS, meaning that the cache libraries can be used without change. Caching in a Distributed Environment 379 Joe Joe starts his shopping cart on A Joe When Joe gets served by B he gets a brand new cart. Cart A is not merged into B. Server A Server B Shopping Empty Cart Cart A Server A Server B Shopping Shopping Cart A Cart B Figure 15.7 Inconsistent cached session data breaking shopping carts.The real beauty of using NFS is that from a user level, it appears no different from anyother filesystem, so it provides a very easy path for growing a cache implementationfrom a single file machine to a cluster of machines. If you have a server that utilizes /cache/www.foo.com as its cache directory, using theCache_File module developed in Chapter 10, “Data Component Caching,” you canextend this caching architecture seamlessly by creating an exportable directory /shares/cache/www.foo.com on your NFS server and then mounting it on any interestedmachine as follows:380 Chapter 15 Building a Distributed Environment #/etc/fstab nfs-server:/shares/cache/www.foo.com /cache/www.foo.com nfs rw,noatime - - Then you can mount it with this: # mount –a These are the drawbacks of using NFS for this type of task: nIt requires an NFS server. In most setups, this is a dedicated NFS server. nThe NFS server is a single point of failure. A number of vendors sell enterprise- quality NFS server appliances.You can also rather easily build a highly available NFS server setup. n The NFS server is often a performance bottleneck.The centralized server must sustain the disk input/output (I/O) load for every Web server’s cache interaction and must transfer that over the network.This can cause both disk and network throughput bottlenecks. A few recommendations can reduce these issues: n Mount your shares by using the noatime option.This turns off file metadata updates when a file is accessed for reads. n Monitor your network traffic closely and use trunked Ethernet/Gigabit Ethernet if your bandwidth grows past 75Mbps. n Take your most senior systems administrator out for a beer and ask her to tune the NFS layer. Every operating system has its quirks in relationship to NFS, so this sort of tuning is very difficult. My favorite quote in regard to this is the following note from the 4.4BSD man pages regarding NFS mounts: Due to the way that Sun RPC is implemented on top of UDP (unreliabl ...

Tài liệu được xem nhiều: