您的位置:首页 > 运维架构 > Nginx

aio nginx gfs

2016-01-30 00:00 591 查看
nginx:

1 which is much more suitable for nonlinear scalability in both the number of simultaneous connections and requests per second

2 nginx is event-based, so it does not follow Apache's style of spawning new processes or threads for each web page request

3 reverse proxy with load balancing and caching

4 pure event-driven web servers

5 It was actually inspired by the ongoing development of advanced event-based mechanisms in a variety of operating systems. What resulted is a modular, event-driven, asynchronous, single-threaded, non-blocking architecture which became the foundation of nginx code.

6 nginx modules come in slightly different incarnations, namely core modules, event modules, phase handlers, protocols, variable handlers, filters, upstreams and load balancers

7 exp:if the load pattern is CPU intensive—for instance, handling a lot of TCP/IP, doing SSL, or compression—the number of nginx
worker
s should match the number of CPU cores; if the load is mostly disk I/O bound—for instance, serving different sets of content from storage, or heavy proxying—the number of
worker
s might be one and a half to two times the number of cores

8 Most notably, combinations of options like sendfile and AIO typically produce a lot of headroom for disk performance

9 The master process is responsible for the following tasks:

reading and validating configuration

creating, binding and closing sockets

starting, terminating and maintaining the configured number of
worker
processes

reconfiguring without service interruption

controlling non-stop binary upgrades (starting new binary and rolling back if necessary)

re-opening log files

compiling embedded Perl scripts

Client sends HTTP request.

nginx core chooses the appropriate phase handler based on the configured location matching the request.

If configured to do so, a load balancer picks an upstream server for proxying.

Phase handler does its job and passes each output buffer to the first filter.

First filter passes the output to the second filter.

Second filter passes the output to third (and so on).

Final response is sent to the client.

nio:

1 、块操作

2、正如前面提到的,所有数据都通过
Buffer
对象来处理。您永远不会将字节直接写入通道中,相反,您是将数据写入包含一个或者多个字节的缓冲区。同样,您不会直接从通道中读取字节,而是将数据从通道读入缓冲区,再从缓冲区获取这个字节。

3、在 NIO 系统中,任何时候执行一个读操作,您都是从通道中读取,但是您不是 直接 从通道读取。因为所有数据最终都驻留在缓冲区中,所以您是从通道读到缓冲区中。

4、读取文件涉及三个步骤:(1) 从
FileInputStream
获取
Channel
,(2) 创建
Buffer
,(3) 将数据从
Channel
读到
Buffer
中。

5、异步 I/O 是一种 没有阻塞地 读写数据的方法。通常,在代码进行
read()
调用时,代码会阻塞直至有可供读取的数据。同样,
write()
调用将会阻塞直至数据能够写入。

异步 I/O 是一种 没有阻塞地 读写数据的方法。通常,在代码进行
read()
调用时,代码会阻塞直至有可供读取的数据。同样,
write()
调用将会阻塞直至数据能够写入。
另一方面,异步 I/O 调用不会阻塞。相反,您将注册对特定 I/O 事件的兴趣 ― 可读的数据的到达、新的套接字连接,等等,而在发生这样的事件时,系统将会告诉您。
异步 I/O 的一个优势在于,它允许您同时根据大量的输入和输出执行 I/O。同步程序常常要求助于轮询,或者创建许许多多的线程以处理大量的连接。使用异步 I/O,您可以监听任何数量的通道上的事件,不用轮询,也不用额外的线程。

gfs:

master主要存储三种类型的元数据:文件和chunk的命名空间,从文件到chunk的映射,每个chunk副本的位置。所有的元数据被保存在master的内存中。前两种也会持久化保存,通过记录操作日志,存储在master的本地磁盘并且复制到远程机器。使用操作日志允许我们更简单可靠的更新master状态,不会因为master的当机导致数据不一致。master不会持久化存储chunk位置,相反,master会在启动时询问每个chunkserver以获取它们各自的chunk位置信息,新chunkserver加入集群时也是如此
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: