Академический Документы
Профессиональный Документы
Культура Документы
0
A Look Under the Hood
CHUUG, June 2002
by Cliff Woolley
jwoolley@apache.org
Introduction
Assumptions
The problems with the design of 1.3
How Apache 2.0 addresses them
Assumptions
Platform Abstraction
Resource Management
Consistency, consistency, consistency
Feature tests
Native OS-specific data structures hidden
behind a consistent interface
Multi-Processing Modules
MPMs defined
MPM configuration
# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers
5
MinSpareServers
5
MaxSpareServers
10
MaxClients
150
MaxRequestsPerChild 0
</IfModule>
MPM configuration
# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule worker.c>
StartServers
2
MaxClients
150
MinSpareThreads
25
MaxSpareThreads
75
ThreadsPerChild
25
MaxRequestsPerChild 0
</IfModule>
Filtered I/O
Bucket Brigades
A convenient abstract data type
What do they look like?
How are they used?
What good are they?
Input filtering
Output filtering
Apache modules
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
module initializer
create per-dir
config structures
merge per-dir
config structures
create per-server config structures
merge per-server config structures
table of config file commands
[#8] MIME-typed-dispatched handlers
[#1] URI to filename translation
[#4] validate user id from request
[#5] check if the user is ok _here_
[#3] check access by host address
[#6] determine MIME type
[#7] pre-run fixups
[#9] log a transaction
[#2] header parser
child_init
child_exit
[#0] post read-request
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
Apache modules
*/
*/
*/
*/
*/
Apache modules
Hooks
Hooks: example
static void register_hooks(apr_pool_t *p)
{
APR_REGISTER_OPTIONAL_FN(ap_ssi_get_tag_and_value);
APR_REGISTER_OPTIONAL_FN(ap_ssi_parse_string);
APR_REGISTER_OPTIONAL_FN(ap_register_include_handler);
ap_hook_post_config(include_post_config, NULL, NULL,
APR_HOOK_REALLY_FIRST);
ap_hook_fixups(include_fixup, NULL, NULL,
APR_HOOK_LAST);
ap_register_output_filter("INCLUDES", includes_filter,
AP_FTYPE_RESOURCE);
}
Conclusion
Questions?