Upload
others
View
8
Download
0
Embed Size (px)
Citation preview
N-tier ColdFusion scalability
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
About me
ColdFusion developer for over 10 yearAdobe Community Expert for ColdFusionCTO for Prisma IT in the Netherlands
consultancydevelopmenthostingtraining
Find me at http://jochem.vandieten.net/[email protected]@houseoffusion.com
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
What do I do
Server stuff CF installation, configuration and troubleshootingWebserversOperating systemsClustering
Infrastructure NetworkingFirewalls & loadbalancingDNS
CF trainingCF development
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
What do you do?
developersystem administratormanagement
Which webserver do you use?
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Which webserver do you use?
IISApacheother
How many tiers have you used?
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
How many tiers have you used?
123456more
Contents
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Contents
DefinitionsTiersScaling the tiersHTTP caching
Scalability
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Scalability
A system whose performance improves after addinghardware, proportionally to the capacity added, is saidto be a scalable system.
http://en.wikipedia.org/wiki/Scalability
Speed and scalability
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Speed and scalability
are fundamentally differentspeed is how fast a single request is processedscalable system do not have to be fastfast systems are not necessarily scalable
Scaling dimensions
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Scaling dimensions
scaling up add more resouces to a nodeCPUsRAMsuited for tightly interconnected processes
scaling out add more nodes to a systemadd a computerpopularized by commodity hardwaresuited for loosely interconnected processes
Partitioning dimensions
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Partitioning dimensions
horizontal partitioning every node does the same as every other nodeit just does it for another domain
East CoastWest Coast
vertical partitioning every node does a specific task
webserverapplication serverdatabase
Tiering semantics
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Tiering semantics
traditional three tier architecture presentation tierbusiness tierdata tier
three tier web architecture web serverapplication serverdatabase server
Tiering semantics
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Tiering semantics
client applicationsproxiesweb serverapplication serverdatabase server
every web application is tiered because the client runs elsewhere
Reasons for N-tier architectures
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Reasons for N-tier architectures
speedscalabilitysecurity
penetrating is like peeling an unionevery tier has wel defined properties
manageability every tier has wel defined propertiesevery tier is individually testable
Scaling the client tier
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Scaling the client tier
completely independent usersusers bring their own resourcesperfect scaling out modelbut not under your control
Scaling the proxy tier
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Scaling the proxy tier
mobile operators and large corporations have their own proxiesContent Delivery Networks offer proxies for hireyou can operate your own proxiesthey are completely independent of eachotherscaling out is trivial
Scaling the webserver tier
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Scaling the webserver tier
scaling out is quite easythe main problem is getting the content on every serveruse a shared / network driveuse file system replication
Scaling the ColdFusion tier
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Scaling the ColdFusion tier
scales up good except for createUUID()createUUID() generates a fixed number of UUIDs per second
scales out OK problem is in memory variablessticky sessions is an accepted solution
Partitioning the ColdFusion tier
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Partitioning the ColdFusion tier
set up specific processes (instances) for specific tasks make the task asynchronous you have used this already: mail spooling it gets better when you do this on a larger scale
Partitioning the ColdFusion tier
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Partitioning the ColdFusion tier
long running processes to partition reportingindexingPDF generation
set up a webservice to offload this to another instance tune your hardware for the task at hand
switch off hyperthreading for PDF generation faster response timessame throughput
tune ColdFusion for the task at hand lower the number of simultaneous threads (3 per core)don't save class files
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Scaling the database tier
scales up pretty good the database is usually the biggest box
scaling out has consequences, pick one no transactional integrityread-only nodeslagn^3 increase of (death)locks
What makes an infrastructure scalable?
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
What makes an infrastructure scalable?
Every tier handles fewer requests then the previous tier
Every tier handles fewer requests
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Every tier handles fewer requests
proxy gets all requestsweb server gets non-cached requestsapplication server gets non-cached dynamic requests
HTTP caching
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
HTTP caching
intended to eliminate requests based on content expirationupstream tells downstream: use this without furtherquestions until Y
intended to eliminate full responses based on content validationdownstream asks upstream: I have version X is that OK
Eliminating full HTTP responses
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Eliminating full HTTP responses
the browser tells the server which version it has If-Modified-Since: Sat, 09 Sep 2006 16:21:52 GMT
the server tells the browser what it sends ETag: Mon, 17 Mar 2008 02:00:00 GMTLast-Modified: Mon, 17 Mar 2008 02:00:00 GMT
the server tells the browser it has not changed HTTP/1.1 304 Not ModifiedETag: Mon, 17 Mar 2008 02:00:00 GMTLast-Modified: Mon, 17 Mar 2008 02:00:00 GMT
ColdFusion caching
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
ColdFusion caching
ColdFusion will not automatically add cache headers
HTTP/1.x 200 OKDate: Tue, 20 May 2008 11:44:02 GMTServer: Apache/2.2.8 (Win32) JRun/4.0Keep-Alive: timeout=5, max=100Connection: Keep-AliveTransfer-Encoding: chunkedContent-Type: text/html; charset=UTF-8
Apache caching
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Apache caching
Apache will automatically add cache headers
HTTP/1.x 200 OKDate: Tue, 20 May 2008 11:46:28 GMTServer: Apache/2.2.8 (Win32) JRun/4.0Last-Modified: Sat, 20 Nov 2004 18:16:26 GMTEtag: "23000000027857-2c-3e9549f1af280"Accept-Ranges: bytesContent-Length: 44Keep-Alive: timeout=5, max=100Connection: Keep-AliveContent-Type: text/html
IIS caching
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
IIS caching
IIS will automatically add cache headers
HTTP/1.x 200 OKServer: Microsoft-IIS/5.1X-Powered-By: ASP.NETDate: Tue, 20 May 2008 11:50:15 GMTContent-Type: text/htmlAccept-Ranges: bytesLast-Modified: Tue, 18 Mar 2008 09:06:48 GMTEtag: "045d65d788c81:911"Content-Length: 30778
Making caching work
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Making caching work
split static and dynamic content in different files caching ColdFusion generated content is a manual processthat you have to work forcaching web server content is partially automatic
split static and dynamic content in different hosts use a CDNno cookies or parameters
static content generation is a form of caching too!
What pays of most?
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
What pays of most?
If all tiers are equally resource constrained
moving work from ColdFusion to the webserver if it doesn't reach ColdFusion, it doesn't read the databaseeither
1.
moving work from the database to ColdFusion2.moving work from the webserver to the proxies3.
Is it worth it?
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Is it worth it?
Imagine the following architecture:
2 datacenterssource based routingloadbalancersreverse proxieswebservers2 CF standard servers2 database servers1 backend CF server
How many hits per minute?
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Questions?
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Security
Ideally tiers communicate with only one protocol for security reasons
webserver and appserver only HTTPappserver and database server only SQL carrier (TDS, NetIQetc.)
this is why you don't want a filesystem databaseif appserver has access to webserver filesystem, the onion iseasier to peelif appserver has access to database filesystem, the onion iseasier to peel
Connecting the webserver and the appserver
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Connecting the webserver and the appserver
Apache mod_proxyJRun connectordistributed modesource on both ends or only on appserver
Apache mod_proxy
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Apache mod_proxy
selectively forward *.cfmfully configurableno ready-made recipesexecutable code only on appserver
JRun connector
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
JRun connector
plug in to webserversplit configuration
webserverconnector .iniweb.xml on JRun
ties in with clustering
Distributed mode
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Distributed mode
needs partial JRun install on webserverties in with clusteringofficially needs source on both serversbut you can work around that
front controller pattern -> only put index.cfm on thewebserveruse wildcard connector and web.xml manipulation
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten
Questions?
N-tier ColdFusion scalability WebManiacs 2008 Jochem van Dieten