4. Application Server
Program that supplies support for running
applications:
Process and thread management
Security
Logging
Interprocess communication
Request dispatching
9. Dynamically rearrange the
DOM (post-delivery) based
on client supplied rules, Web
services, and browser
context
10. Rule Language
rule frequent_archive_visitor is active {
select using "/archives/d+/d+/" setting ()
pre {
c = counter.archive_pages;
}
if counter.archive_pages > 2 within 3 days then {
replace_html("prize_div",
"You win the prize! You've seen " +
c +
" pages from the archives!")
}
fired {
clear counter.archive_pages;
} else {
counter.archive_pages += 1 from 1;
}
}
16. Architecture Decisions
Implement rule interpreter as an
Apache module
No database for scalability
No session pinning
Store rules in versioned repository
21. Modules are NOT CGI Programs
Modules run inside the Apache process
architecture
Modules have access to and can replace
all Apache ser vices
Uses the ser ver API - not an embedded
interpreter
Access to every part of the HTTP
request lifecycle
25. Apache Application Ser vices
Configuration
Process and thread management
Security
Logging
Interprocess communication
Request dispatching
26. Configuration Support
Via Apache configuration file
Setting variables that can be seen in Perl
$r->dir_config('memcached_hosts')
27. Configuration
<LocationMatch /kobj/>
# env var to turn on rule logging
PerlSetEnv KOBJ 1
# host names
PerlSetVar init_host init
PerlSetVar log_host logger
PerlSetVar action_host cs
PerlSetVar frag_host frag
# mode => development, production, test
PerlSetVar run_mode development
PerlSetVar memcached_hosts 192.168.2.2
PerlAddVar memcached_hosts 192.168.2.3
SetHandler perl-script
PerlHandler Kynetx # Perl module name
</LocationMatch>
28. Process & Thread Management
Apache 2.X uses multi-processing modules
(MPMs) to provide a flexible way to change the
execution model
prefork - Apache 1.3
worker - Hybrid, based on pthreads
OS specific - Windows, BeOS, etc.
perchild - virtual hosts with custom UID’s
32. Security
Apache HTTP access, authentication, and
authorization (AAA) isn’t very good for
people
HTTP AAA works fine for machines (usually)
Standard
mod_auth
mod_access
You can also override the AAA phases of the
HTTP request cycle
40. Request Dispatching
Request dispatching says what to do for
each URL or URL pattern
Turns out that Apache is really good at this
Request dispatching is known as “routes” in
Rails