`
haohappy2
  • 浏览: 314028 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Apache Optimization

阅读更多

Multi-Processing Module (MPM) implements a hybrid multi-process multi-threaded server。(多进程、多线程)

大致有:prefork MPM、worker MPM、BeOS MPM、NetWare MPM、OS/2 MPM、WinNT MPM。  


linux及windows下都可以使用命令:“httpd -l ” 进行查询。

各个MPM是工作及及优化
(1)prefork MPM
        <IfModule mpm_prefork_module>
            StartServers                10
            MinSpareServers        10
            MaxSpareServers        15
            ServerLimit                  2000
            MaxClients                   1000
            MaxRequestsPerChild 10000
        </IfModule>
        启动时建立StartServers个子进程,
        然后按每秒创建指数级个进程直到达到MinSpareServers个进程(最多增到每秒32个),
        如果空闲进程数大于MaxSpareServers,则检查kill掉一些空闲进程。
        MaxRequestPerChild指定每个进程处理了多少个请求后就自我毁灭。
        MaxClients指定apache最多可以同时处理的请求数,也就是进程数?
        MaxClients默认不能大于256,可以通过设定ServerLimit来增大这个限制数,最大20000?

(2)worker:
        <IfModule mpm_worker_module>
            StartServers                  3
            MaxClients                     2000
            ServerLimit                    25
            ThreadLimit                   200
            ThreadsPerChild            100
            MinSpareThreads         50
            MaxSpareThreads        200
            MaxRequestsPerChild   0
        </IfModule>
        启动时建立StartServers个子进程,
        每个进程包含ThreadsPerChild个线程,缺省最大64
        MinSpareThreads定义最小的空闲线程数,最大75
        MaxSpareThreads定义最大的空闲线程数,超过则执行清理?最大250
        MaxClients定义所有子进程中的线程总数
        ThreadLimit,最大20000,默认64
        ServerLimit,最大值20000,默认16
        需要注意的是,如果显式声明了ServerLimit,那么它乘以ThreadsPerChild的值必须大于等于MaxClients,而且 MaxClients必须是ThreadsPerChild的整数倍,否则Apache将会自动调节到一个相应值(可能是个非期望值)。

(3)WinNT MPM:
        <IfModule mpm_winnt_module>
            ThreadsPerChild         500
            MaxRequestsPerChild 10000
        </IfModule>
        mpm_winnt.c是专门针对Windows NT优化的MPM(多路处理模块),它使用一个单独的父进程产生一个单独的子进程,在这个子进程中轮流产生多个线程来处理请求。也就是说 mpm_winnt只能启动父子两个进程, 不能像Linux下那样同时启动多个进程。
ThreadLimit,默认1920,最大15000,限制单个进程的线程总数。

 

 

Apache worker optimzation

我的worker.c配置如下:

<IfModule worker.c>
ServerLimit 64
ThreadLimit 200
StartServers 5
MaxClients 2500
MinSpareThreads 50
maxSpareThreads 200
ThreadsPerChild 100
MaxRequestsPerChild 1000
</IfModule>

 

\\大家自己根据机子的配置设定,同时记住公式,不然启动APACHE会报错

注意
对于KeepAlive链接,只有第一个请求会被计数。事实上,它改变了每个子进程限制最大链接数量的行为。

ThreadLimit >= ThreadsPerChild
MaxClients <= ServerLimit * ThreadsPerChild 必须是ThreadsPerChild的倍数
MaxSpareThreads >= MinSpareThreads+ThreadsPerChild

 

ServerLimit 16
//服务器允许配置的进程数上限。这个指令和ThreadLimit结合使用设置了MaxClients最大允许配置的数值。任何在重启期间对这个指令的改变都将被忽略,但对MaxClients的修改却会生效。
ThreadLimit 64
//每个子进程可配置的线程数上限。这个指令设置了每个子进程可配置的线程数ThreadsPerChild上限。任何在重启期间对这个指令的改变都将被忽略,但对ThreadsPerChild的修改却会生效。默认值是”64″.
StartServers 3
//服务器启动时建立的子进程数,默认值是”3″。
MinSpareThreads 75
//最小空闲线程数,默认值是”75″。这个MPM将基于整个服务器监视空闲线程数。如果服务器中总的空闲线程数太少,子进程将产生新的空闲线程。
MaxSpareThreads 250
//设置最大空闲线程数。默认值是”250″。这个MPM将基于整个服务器监视空闲线程数。如果服务器中总的空闲线程数太多,子进程将杀死多余的空闲线 程。MaxSpareThreads的取值范围是有限制的。Apache将按照如下限制自动修正你设置的值:worker要求其大于等于 MinSpareThreads加上ThreadsPerChild的和
MaxClients 400
//允许同时伺服的最大接入请求数量(最大线程数量)。任何超过MaxClients限制的请求都将进入等候队列。默认值是”400″ ,16(ServerLimit)乘以25(ThreadsPerChild)的结果。因此要增加MaxClients的时候,你必须同时增加 ServerLimit的值。
ThreadsPerChild 25
//每个子进程建立的常驻的执行线程数。默认值是25。子进程在启动时建立这些线程后就不再建立新的线程了。
MaxRequestsPerChild 0
//设置每个子进程在其生存期内允许伺服的最大请求数量。到达MaxRequestsPerChild的限制后,子进程将会结束。如果MaxRequestsPerChild为”0″,子进程将永远不会结束。
将MaxRequestsPerChild设置成非零值有两个好处:
1.可以防止(偶然的)内存泄漏无限进行,从而耗尽内存。
2.给进程一个有限寿命,从而有助于当服务器负载减轻的时候减少活动进程的数量。

分享到:
评论

相关推荐

    藏经阁-SparkOscope--Enabling Apache Spark Optimization through Cros

    藏经阁-SparkOscope--Enabling Apache Spark Optimization through Cross Stack Monitoring and Visualization.pdf

    Optimization of apache web server

    apache web服务器性能优化

    Beginning Apache Pig(Apress,2016)

    Learn to use Apache Pig to develop lightweight big data applications easily and quickly. This book shows you many optimization techniques and covers every context where Pig is used in big data ...

    Beginning Apache Pig: Big Data Processing Made Easy [2016]

    Beginning Apache Pig: Big Data Processing Made Easy English | 29 Dec. 2016 | ISBN: 1484223365 | 300 Pages | PDF | 4.9 MB Learn to use Apache Pig to develop lightweight big data applications easily ...

    Learning Apache Flink电子版

    The final part of the book would consist of topics such as scaling Flink solutions, performance optimization, and integrating Flink with other tools such as Hadoop, ElasticSearch, Cassandra, and ...

    Apache Spark 2.x Cookbook

    Last but not least, the final few chapters delve deeper into the concepts of graph processing using GraphX, securing your implementations, cluster optimization, and troubleshooting. What you will ...

    Big.Data.Benchmarks.Performance.Optimization.and.Emerging.Hardware

    Chapter 10 A Plugin-Based Approach to Exploit RDMA Benefits for Apache and Enterprise HDFS Chapter 11 Stream-Based Lossless Data Compression Hardware Using Adaptive Frequency Table Management

    Next-Generation Big Data: A Practical Guide to Apache Kudu, Impala, and Spark

    Install Apache Kudu, Impala, and Spark to modernize enterprise data warehouse and business intelligence environments, complete with real-world, easy-to-follow examples, and practical advice ...

    ChatGPT-Prompt-template-Solr Search Engine 轻松创建和搜索由 Apache Solr

    轻松创建和搜索由 Apache Solr 提供支持的集合 Ignore all previous instructions. You are an expert in search engine optimization and query optimization, specializing in Solr. You have helped many people ...

    Spark Summit 2019 部分PPT

    Analyzing 2TB of Raw Trace Data from a Manufacturing Process A First Use Case of Apache Spark for Semiconductor Wafers from Real Industry Cosco an efficientfacebook-scale shuffle service Building ...

    spark-ml-optimization

    spark-ml优化 这些是针对ML分类器进行大规模优化的Spark实现。 支持以下算法:IPA(迭代参数平均),PH(渐进对冲)和ADMM(乘数的交替方向方法)。 可以在以下博客中找到算法和实现的描述: : (个人博客)或 ...

    tensorflow_constrained_optimization-0.2.tar.gz

    TensorFlow最初由Google Brain团队(属于Google的人工智能部门)开发,并在2015年被发布到Apache 2.0开源许可证下。 TensorFlow的主要特点包括它的高度灵活性、可扩展性和可移植性。它支持从小到大的各种计算,从...

    tensorflow_constrained_optimization-0.1.tar.gz

    TensorFlow最初由Google Brain团队(属于Google的人工智能部门)开发,并在2015年被发布到Apache 2.0开源许可证下。 TensorFlow的主要特点包括它的高度灵活性、可扩展性和可移植性。它支持从小到大的各种计算,从...

    tensorflow_constrained_optimization-0.2-py2.py3-none-any.whl

    TensorFlow最初由Google Brain团队(属于Google的人工智能部门)开发,并在2015年被发布到Apache 2.0开源许可证下。 TensorFlow的主要特点包括它的高度灵活性、可扩展性和可移植性。它支持从小到大的各种计算,从...

    tensorflow_constrained_optimization-0.1-py2.py3-none-any.whl

    TensorFlow最初由Google Brain团队(属于Google的人工智能部门)开发,并在2015年被发布到Apache 2.0开源许可证下。 TensorFlow的主要特点包括它的高度灵活性、可扩展性和可移植性。它支持从小到大的各种计算,从...

    Spark.Cookbook.1783987065

    After mastering graph processing using GraphX, you will cover various recipes for cluster optimization and troubleshooting. Table of Contents Chapter 1: Getting Started with Apache Spark Chapter 2: ...

    Data Algorithms(O'Reilly,2016)

    this practical book takes you step by step through the algorithms and tools you need to build distributed MapReduce applications with Apache Hadoop or Apache Spark. Each chapter provides a recipe for...

    QuadraticProblemExample2:使用 Apache Commons Math3 (3.4API)

    二次问题Example2 这些是 Apache Commons Math (API 3.4) 的 Levenberg-Marquardt 方法的二次问题优化示例代码。 大部分源代码来源于[Apache Commons Math - 12 Optimization-]的用户指南( )。 谢谢你。 新井义之

    website-optimization_3

    通过在运行 apache 的 http 服务器上使用 java 上传文件来运行 index.html,运行该文件的更简单方法是使用浏览器(例如 google chrome 或 firefox)并通过将文件拖到浏览器中来打开该文件 为了测试帧率,使用谷歌...

    php_memcache.dll Or php_opcache.dll For PHP5.3.27

    测试平台:Windows 2008 R2 x64 (IIS7.5 FastCGI,Apache2.2.23,Apache2.4.3, Nginx 1.2.9) 包含 Non Thread Safe 和 Thread Safe 如果用的是 FastCGI 请使用 Non Thread Safe 版 php_opcache.dll 的使用方法 ...

Global site tag (gtag.js) - Google Analytics