日期:2014-05-16 浏览次数:20928 次
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 必须同时处理多个连接