首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > Apache >

Apache Architecture - Aaron Bannert 通译

2012-12-24 
Apache Architecture -- Aaron Bannert 翻译Apache Architecture:How do we measure performance? 如何测

Apache Architecture -- Aaron Bannert 翻译

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?

?

热点排行