aio nginx gfs

nginx:

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

reverse proxy with load balancing and caching 

pure event-driven web servers

 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.

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 workers 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 workers might be one and a half to two times the number of cores

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

  1. Client sends HTTP request.

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

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

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

  5. First filter passes the output to the second filter.

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

  7. 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加入集群时也是如此

转载于:https://my.oschina.net/u/2421352/blog/611733

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值