设为首页 收藏本站
查看: 690|回复: 0

[经验分享] Apache Architecture -- Aaron Bannert 翻译

[复制链接]

尚未签到

发表于 2017-1-3 09:42:06 | 显示全部楼层 |阅读模式
    Apache Architecture:
  How do we measure performance? 如何测量web服务器的性能?
  –Requests per Second 每秒请求次数
  –Bandwidth 带宽
  –Latency 等待时间
  –Concurrency (Scalability) 并发(可扩展)
  Building a scalable web server:设计可扩展的web server
  handling an HTTP request 处理http请求
  –map the URL to a resource 将url映射成资源
  –check whether client has permission to access the resource 检查客户端是否有访问资源的权限 –choose a handler and generate a response 选择处理器和生成响应
  –transmit the response to the client 发送响应到客户端
  –log the request 记录请求日志
  must handle many clients simultaneously 必须同时处理多个请求
  must do this as fast as possible 必须尽可能快的处理
  Resource Pools:资源池
  one bottleneck to server performance is the operating system 服务器性能瓶颈之一是操作系统
  –system calls to allocate memory, access a file, or create a child process take significant amounts of time
  分配内存,访问文件和创建子进程的系统调用会消耗大量时间
  –as with many scaling problems in computer systems, caching is one solution
  计算机系统中的许多扩展性的问题,缓存是一种解决方法
  resource pool: application-level data structure to allocate and cache resources 应用层数据存储的分配和缓存资源
  –allocate and free memory in the application instead of using a system call 
  在应用中分配和释放内存,用来代替使用系统调用
  –cache files, URL mappings, recent responses 
  缓存文件,url映射,最近产生的回复(响应)
  –limits critical functions to a small, well-tested part of code 
  把至关重要的函数限制到小的,充分测试的代码
  Multi-Processor Architectures:多处理器体系结构
  a critical factor in web server performance is how each new connection is handled
  web服务器性能至关重要的因素之一就是每一个连接如何被处理
  –common optimization strategy: identify the most commonly-executed code and make this run as fast as possible
  通常的优化策略:识别最频繁执行的代码并且让它执行的尽可能快
  –common case: accept a client and return several static objects
  通常的情况:接受客户端请求,返回几个静态对象
  –make this run fast: pre-allocate a process or thread, cache commonly-used files and the HTTP message for the response
  让这运行的更快:预分配线程或进程,缓存经常使用的文件和http消息
  Connections:连接
  must multiplex handling many connections simultaneously 必须同时处理多个连接
  –select(), poll(): event-driven, singly-threaded 事件驱动,单线程的
  –fork(): create a new process for a connection 为每个连接创建一个进程 
  –pthread create(): create a new thread for a connection 为每个连接创建一个线程
  synchronization among processes/threads 进程/线程间同步
  –shared memory: semaphores message passing 共享内存:信号消息传递
  Select:
  select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
  Allows a process to block until data is available on any one of a set of file descriptors.
  允许进程阻断,直到一系列文件描述符中的一个准备好
  One web server process can service hundards of socket connections
  一个web服务器进程可以服务于几百个连接
  Event Driven Architecture:事件驱动体系结构
  one process handles all events 一个进程处理多个事件
  must multiplex handling of many clients and their messages 
  必须多路处理多个客户端和它们的消息
  use select() or poll() to multiplex socket I/O events 使用select或poll来多路复用io事件
  provide a list of sockets waiting for I/O events 提供一个socket列表来等待io事件
  sleeps until an event occurs on one or more sockets 休眠直到多个socket的事件发生
  can provide a timeout to limit waiting time 可以提供一个超时时间来限制等待时间
  must use non-blocking system calls 必须使用非阻塞系统调用
  some evidence that it can be more efficient than process or thread architectures 一些证据表明比进线程更有效率
  Process Driven Architecture:进程驱动体系结构
  devote a separate process/thread to each event 每个线程或进程专注于一个事件
  master process listens for connections 主进程监听连接
  master creates a separate process/thread for each new connection 主进程为每一个连接创建独立的进程/线程
  performance considerations 性能考虑
  creating a new process involves significant overhead 创建一个进程需要大量的系统开销
  threads are less expensive, but still involve overhead 线程相比少了很多,但仍然需要系统开销
  may create too many processes/threads on a busy server 可能在一个繁忙的服务器上创建太多的进程/线程
  Process/Thread Pool Architecture:进程/线程池体系结构:
  master thread 主线程
  creates a pool of threads 创建线程池
  listens for incoming connections 监听到来的连接
  places connections on a shared queue 把连接放到共享队列
  processes/threads 进程/线程
  take connections from shared queue 从共享队列里获取线程
  handle one I/O event for the connection 为每个连接处理io事件
  return connection to the queue 返回连接给队列
  live for a certain number of events (prevents long-lived memory leaks) 有一定数量的事件(阻止长寿命的内存泄露)
  need memory synchronization 需要内存同步
  Hybrid Architectures:复杂体系结构:
  each process can handle multiple requests 每一个进程处理多个请求
  each process is an event-driven server 每一个进程是一个事件驱动服务器
  must coordinate switching among events/requests 必须在事件和请求间切换
  each process controls several threads 每一个进程控制几个线程
  threads can share resources easily 线程间可以容易的共享资源
  requires some synchronization primitives 需要一些同步原语
  event driven server that handles fast tasks but spawns helper processes for time-consuming requests
  事件驱动服务器处理快速任务,而生成助手进程来处理耗时的请求
  What makes a good Web Server?:什么东西可以设计一个优秀的web服务器
  Correctness 准确性
  Reliability 可靠性
  Scalability 可扩展性
  Stability 稳定性
  Speed 速度
  Correctness 准确性
  Does it conform to the HTTP specification? 符合http协议标准吗?
  Does it work with every browser? 对每一个浏览器起作用吗?
  Does it handle erroneous input gracefully? 能优雅的处理错误的输入吗?
  Reliability 可靠性
  Can you sleep at night? 你晚上可以休息吗?
  Are you being paged during dinner? 吃晚饭的时候被打断了吗?
  It is an appliance? 这是一个设备,工具?
  Scalability 可扩展性
  Does it handle nominal load? 它可以处理标称的负载吗?
  Have you been Slashdotted? 
  And did you survive?
  What is your peak load? 峰值负载时多少?
  Speed 速度
  Does it feel fast? 速度快吗?
  Do pages snap in quickly? 
  Do users often reload pages?

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-323107-1-1.html 上篇帖子: Apache Ant 实例介绍 下篇帖子: 【转】Apache Mina 网络通信
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表