© 2014 Progress Software Corporation. All rights reserved. 4
Twitter’s – Scalability Problem
Takeaways from the story of Twitter • Understand your software’s behavior and foresee its usage • Have a mechanism to identify Production issues and raise an alarm smartly
before your customers do it • Scalability acts as a key measure for the Quality of a Software
© 2014 Progress Software Corporation. All rights reserved. 5
Agenda
OpenEdge Applications and Focus Areas for Scalability
Optimization Techniques for Appserver
Tomcat Web Server
• Tuning Techniques
• Different Types of Tomcat Connectors
Scaling OpenEdge Applications With Load Balancing
Q&A
© 2014 Progress Software Corporation. All rights reserved. 6
Focus for Scalability in Progress OpenEdge Components
Presentation Layer OpenEdge Clients Open Clients Rollbase Mobile
Application Server OpenEdge Appserver
Database Server OpenEdge RDBMS OpenEdge Replication
Enterprise Services JMS Web Services ESB
Where to focus on scalability ?
© 2014 Progress Software Corporation. All rights reserved. 7
OpenEdge Appservers and Applications
Classic Appserver
Pacific Appserver for OE
Web Server (OpenEdge Services/
Applications)
2 3
1 OpenEdge Appservers
OpenEdge
Non-OpenEdge Clients
© 2014 Progress Software Corporation. All rights reserved. 8
Key Areas to be Focused for Scalability
Classic Appserver Webserver(Tomcat) Load Balancing
Most of the OpenEdge Adapters and certified using standard Java Container, which is Tomcat
Tomcat acts a Java Container for “Pacific AS for OE”
Optimization Techniques
Properties for high concurrency
Tuning techniques
Different Tomcat Connectors and their uses
Best Practices
Types of load balancing to be applied for OpenEdge applications
Methods for applying load balancing
Why Tomcat?
© 2014 Progress Software Corporation. All rights reserved. 9
Typical Issues With Application Servers
No response from the server
Client request takes too long to execute
Server goes down very often
• Out of Memory
• Out of Heap space
• All kinds of requests goes to the same server
Web server needs to be restarted as the Application needs to be upgraded
Cannot execute more than a specific number of requests
© 2014 Progress Software Corporation. All rights reserved. 11
Tuning Options of Classic Appserver
maxClientInstance • Set to 512 by default
Heap Memory of the broker process • jvmArgs=-Xms<value> -Xmx<value>
Queuelimit • (Size of the Payload)/8k =
Queuelimit value
Deleting Persistent and Connection Procedures
Classic Appserver
Client Requests
ABL
Web Clients Open
Clients
© 2014 Progress Software Corporation. All rights reserved. 12
OpenEdge Applications and its Environment
Mobile Clients
Webspeed Adapter
SOAP Adapter
AIA Adapter
REST Adapter
SOAP Clients
Webspeed Clients
OpenEdge Appserver
OpenEdge Services/Applications
OpenEdge Appserver OpenEdge Appserver
Web Server
© 2014 Progress Software Corporation. All rights reserved. 14
Handles communications between client and the Engine
Highest level of Container for processing servlets
Web Applications deployed in multiple hosts
Instance of the Tomcat Web Application Server which
contains one or more services
Routes requests between Clients and Web Applications
Server
Service
Tomcat and its Pieces
Engine
Host1
WebApp1
WebApp2
Host2
WebApp3
WebApp4
Connectors
© 2014 Progress Software Corporation. All rights reserved. 15
Tuning Options in Tomcat Webserver
Tuning Webserver to scale for maximum client requests
JVM Tuning Threads and its
Properties
Compression Cache for Static Files
© 2014 Progress Software Corporation. All rights reserved. 16
Tuning Options in Tomcat Webserver – JVM Tuning
The defaults are not for the Production Environment
Higher heap memory causes long pauses in Garbage Collection which will be affected in the response time
Know your needs and configure optimistic memory
Permgen space – Optimistic approach is to set almost 25–30% of total Java heap memory
JAVA_OPTS -Xms <value> -Xmx <value> -XX:MaxGCPauseMillis <value>
-XX:+PrintGC -XX:+PrintGCDetails
setenv.{bat/sh}
JVM Tuning Threads and its
Properties
Compression Cache for Static Files
© 2014 Progress Software Corporation. All rights reserved. 17
Tuning Options in Tomcat Webserver – Threads
JVM Tuning Threads and its
Properties
Compression Cache for Static Files
minSpareThreads(10) maxThreads(50)
Con
curr
ent U
ser R
eque
sts
Threads Configuration + acceptCount(50)
Further client requests will be refused
OS buffers TCP (kernel’s listen queue)
Accept Count
AcceptCount ∝ Kernel’s listen queue
Maxthreads : 200 – 800 Optimize based on your Application
© 2014 Progress Software Corporation. All rights reserved. 18
Tuning Options in Tomcat Webserver – Monitoring Threads
Properties can be configured in server.xml as below <Connector port="8080“ connectionTimeout="20000“ maxThreads="500“ />
http://<hostname>:<port>/manager Server Status
© 2014 Progress Software Corporation. All rights reserved. 19
Tuning Options in Tomcat Webserver – Compression
Compression • Reduces the network payload but gobbles the computational power • Client and the webserver both should be configured for compression
0 2000 4000 6000 8000
10000 12000 14000 16000 18000
Create Update Read Delete
Exec
utio
n Ti
me
in m
s
Operations Performed
Client Execution Time for the Payload of 10000 Records
Compression Disabled Compression Enabled
Improvement of 110% in execution time after enabling compression
Network Payload/Bytes Transferred were
150 times less with compression
© 2014 Progress Software Corporation. All rights reserved. 20
Tuning Options in Tomcat Webserver – Caching Static files
Allows caching the static files in the browser with a future expiration date
Reduces the load of calling the static files every time from the webserver
Mostly used for css, images, javascript and static html
JVM Tuning Threads and its
Properties
Compression Cache for Static Files
<Context cacheMaxSize=”10240” cacheTTL=”60000” cachingAllowed=”true”>
content.xml
© 2014 Progress Software Corporation. All rights reserved. 22
Tomcat Connectors – From the Perspective of OpenEdge
Server
Connectors
HTTP & AJP
Handles communications client and the Engi
Listens on a defined single port for connections
Engine
Web Applications
Ubroker
Starts Agents
OpenEdge Clients
Handles and manages communication between Client and Agent
ABL Business Logic
Agents
http://localhost:8080
AJP – Apache Jserv Protocol HTTP - HTTP 1.1 Protocol
© 2014 Progress Software Corporation. All rights reserved. 23
Tomcat Connectors – HTTP
BIO Connector • Executes multiple requests on multiple threads
• Stable performance for applications with moderate traffic
• Consumes more system resources on a burst of requests
NIO Connector • Handles multiple connections using a couple
of poller threads
• Better managing of threads which shares threads for multiple concurrent users
APR Connector • Uses Apache Native Runtime library
• Mostly used for SSL as it uses OpenSSL library which is fastest
HTTP AJP
Web Server
HTTP – HTTP 1.1 Protocol
BIO – Blocking Input Output
NIO – Non-blocking Input Output
APR – Apache Portable Runtime
© 2014 Progress Software Corporation. All rights reserved. 24
Tomcat HTTP Connectors – Which One to Choose
Option-1 Option-2
Stability BIO APR SSL APR NIO Low Concurrency BIO APR High Concurrency No Keep-Alive BIO APR High Concurrency Keep-Alive APR NIO
© 2014 Progress Software Corporation. All rights reserved. 25
Tomcat Connectors – AJP
Tomcat to Apache over a Wire Protocol
Mostly used to serve tomcat behind Apache httpd and handle the traffic to the Tomcat clusters
Apache serves better static content and better caching mechanism
Secures tomcat with its inbuilt security features and third party libraries
Widely used as secure proxy servers
Examples – modjk, mod_proxy, mod_http_proxy
HTTP AJP
Tomcat Connectors – Why AJP
AJP – Apache Jserv Protocol
© 2014 Progress Software Corporation. All rights reserved. 26
After Applying Tuning in Appserver and Webserver
What if your application is getting more and more hits • Followed all tuning possibilities and best practices
– Optimal JVM options, heap space etc. – Choosing right Connector for the Application – Enabled Compression – Optimal number of threads, connection timeouts
• What might go wrong – More and more requests conquer your webserver – Webserver Out of Memory – Client Requests exceeds the maximum number
of requests
Is adding more Computational resources
an ultimate solution for Scalability?
With all the tuning options, can we take
advantage of horizontal scalability?
© 2014 Progress Software Corporation. All rights reserved. 27
Applying Scalability with a Load Balancer
Webspeed Adapter
SOAP Adapter
AIA Adapter
REST Adapter
OpenEdge Appserver
OpenEdge Services/Applications
OpenEdge Appserver OpenEdge Appserver
Web Server Instance 1
Webspeed Adapter
SOAP Adapter
AIA Adapter
REST Adapter
OpenEdge Appserver
OpenEdge Services/Applications
OpenEdge Appserver OpenEdge Appserver
Web Server Instance 2
Nameserver(alike)
Mobile Clients
SOAP Clients
Webspeed
Clients
© 2014 Progress Software Corporation. All rights reserved. 28
Applying Scalability with a Load Balancer
Webspeed Adapter
SOAP Adapter
AIA Adapter
REST Adapter
OpenEdge Appserver
OpenEdge Services/Applications
OpenEdge Appserver OpenEdge Appserver
Web Server Instance 1
Webspeed Adapter
SOAP Adapter
AIA Adapter
REST Adapter
OpenEdge Appserver
OpenEdge Services/Applications
OpenEdge Appserver OpenEdge Appserver
Web Server Instance 2
Nameserver(alike)
Mobile Clients
SOAP Clients
Webspeed
Clients
© 2014 Progress Software Corporation. All rights reserved. 29
Applying Scalability with a Load Balancer
Webspeed Adapter
SOAP Adapter
AIA Adapter
REST Adapter
OpenEdge Appserver
OpenEdge Services/Applications
OpenEdge Appserver OpenEdge Appserver
Web Server Instance 1
Webspeed Adapter
SOAP Adapter
AIA Adapter
REST Adapter
OpenEdge Appserver
OpenEdge Services/Applications
OpenEdge Appserver OpenEdge Appserver
Web Server Instance 2
Load Balancing using AJP
Mobile Clients
SOAP Clients
Webspeed
Clients
© 2014 Progress Software Corporation. All rights reserved. 31
Load Balancing With Apache
Tomcat instance 2
Tomcat instance 4
Tomcat instance 3
Tomcat instance 1
Apache HTTPD
Load Balancer
(mod_jk)
Configurations Tomcat – Set the AJP Port Mod_jk – Configure worker.properties with Tomcat instances details Apache HTTPD – Configure to send the traffic to the balancer
© 2014 Progress Software Corporation. All rights reserved. 32
Load Balancing With Apache
Mod_jk Configuration • Mod_jk acts a load balancer that is configured in the Apache HTTPD Server
• Properties of this connector is configured in worker.properties file
• Structure of the properties file – Worker.<tomcat node>.type = ajp13
– Worker.<tomcat-node>.port = <ajp port>
– Worker.<tomcat-node>.host = < hostname of the tomcat-node>
– Worker.list = <list of workers>
– Worker.balancer.type = lb
– Worker.balancer.balancer_workers = <tomcat-node1>,<tomcat-node2>
– Worker.stat.type = <any defined name for your worker status>
Generic Properties
Properties for Each Node
© 2014 Progress Software Corporation. All rights reserved. 33
Load Balancing With Apache
Tomcat instance 2
Tomcat instance 4
Tomcat instance 3
Tomcat instance 1
Apache HTTPD
Load Balancer
(mod_jk)
http://<hostname>:<apacheport>/myApp
1st Request
© 2014 Progress Software Corporation. All rights reserved. 34
Load Balancing With Apache
Tomcat instance 2
Tomcat instance 4
Tomcat instance 3
Tomcat instance 1
Apache HTTPD
Load Balancer
(mod_jk)
http://<hostname>:<apacheport>/myApp
2nd Request
© 2014 Progress Software Corporation. All rights reserved. 35
Load Balancing With Apache
Tomcat instance 2
Tomcat instance 4
Tomcat instance 3
Tomcat instance 1
Apache HTTPD
Load Balancer
(mod_jk)
http://<hostname>:<apacheport>/myApp
3rd Request
© 2014 Progress Software Corporation. All rights reserved. 36
Load Balancing With Apache
Tomcat instance 2
Tomcat instance 4
Tomcat instance 3
Tomcat instance 1
Apache HTTPD
Load Balancer
(mod_jk)
http://<hostname>:<apacheport>/myApp
4th Request
© 2014 Progress Software Corporation. All rights reserved. 37
Load Balancing With Apache
Tomcat stance 2
Tomcat instance 4
Tomcat instance 3
Tomcat instance 1
Apache HTTPD
Load Balancer
(mod_jk)
http://<hostname>:<apacheport>/myApp
X
© 2014 Progress Software Corporation. All rights reserved. 38
Load Balancing With Apache
Tomcat stance 2
Tomcat instance 4
Tomcat instance 3
Tomcat instance 1
Apache HTTPD
Load Balancer
(mod_jk)
http://<hostname>:<apacheport>/myApp
5th Request
X
© 2014 Progress Software Corporation. All rights reserved. 39
Load Balancing With Apache
Tomcat stance 2
Tomcat instance 4
Tomcat instance 3
Tomcat instance 1
Apache HTTPD
Load Balancer
(mod_jk)
http://<hostname>:<apacheport>/myApp
6th Request
X
© 2014 Progress Software Corporation. All rights reserved. 40
Load Balancing With Tomcat Clusters
Basic Load Balancer Sticky Sessions/ Session Affinity Session Replication
Allows a user to route the traffic across different nodes
Persists the users session for a single node
Replicates the session across multiple nodes of the load balancer
HTTP Stateless Clients HTTP Stateful Clients
© 2014 Progress Software Corporation. All rights reserved. 41
Load Balancing With Tomcat Clusters
Session Replication • Provides High Availability and Fail-over tolerance in a clustered environment
• Enable multicast routing in your server machine
• Enable/Add Cluster configuration in Tomcat
• Add <distributable> tag to the Web Application
Enables all the cluster nodes join the multicast group and sends the heartbeat
signals for certain intervals
As part of creating and managing the session, it replicates the session to all
tomcat nodes
Multicast Tomcat Session Manager
Configuring Session Replication
© 2014 Progress Software Corporation. All rights reserved. 42
Load Balancing With Tomcat Clusters
Tomcat instance 2
Tomcat instance 4
Tomcat instance 3
Tomcat instance 1
Apache HTTPD
Load Balancer
(mod_jk)
http://<hostname>:<apacheport>/myApp
1st Request
Session Context
Session created for 1st Request
© 2014 Progress Software Corporation. All rights reserved. 43
Load Balancing With Tomcat Clusters
Tomcat instance 2
Tomcat instance 4
Tomcat instance 3
Tomcat instance 1
Apache HTTPD
Load Balancer
(mod_jk)
http://<hostname>:<apacheport>/myApp
1st Request
Session Context
Replicating the session across multiple instances using Apache Tribes Group
© 2014 Progress Software Corporation. All rights reserved. 44
Load Balancing With Tomcat Clusters
Tomcat instance 2
Tomcat instance 4
Tomcat instance 3
Tomcat instance 1
Apache HTTPD
Load Balancer
(mod_jk)
http://<hostname>:<apacheport>/myApp
1st Request
Session Context
Session Context
Session Context
Session Context
© 2014 Progress Software Corporation. All rights reserved. 45
Load Balancing With Tomcat Clusters
Tomcat instance 2
Tomcat instance 4
Tomcat instance 3
Tomcat instance 1
Apache HTTPD
Load Balancer
(mod_jk)
http://<hostname>:<apacheport>/myApp
2nd Request
Session Context
Session Context
Session Context
Session Context
© 2014 Progress Software Corporation. All rights reserved. 46
Load Balancing With Tomcat Clusters
Tomcat instance 2
Tomcat instance 4
Tomcat instance 3
Tomcat instance 1
Apache HTTPD
Load Balancer
(mod_jk)
http://<hostname>:<apacheport>/myApp
3rd Request
Session Context
Session Context
Session Context
Session Context
© 2014 Progress Software Corporation. All rights reserved. 47
Load Balancing With Tomcat Clusters
Tomcat instance 2
Tomcat instance 4
Tomcat instance 3
Tomcat instance 1
Apache HTTPD
Load Balancer
(mod_jk)
http://<hostname>:<apacheport>/myApp
4th Request
Session Context
Session Context
Session Context
Session Context
© 2014 Progress Software Corporation. All rights reserved. 48
Load Balancing With Tomcat Clusters
Tomcat instance 2
Tomcat instance 4
Tomcat instance 3
Tomcat tance 1
Apache HTTPD
Load Balancer
(mod_jk)
http://<hostname>:<apacheport>/myApp
4th Request
Session Context
Session Context
Session Context
Session Context
X
© 2014 Progress Software Corporation. All rights reserved. 49
Summary
Classic Appserver
Tomcat Web Server
Load Balancing
1. Tuning Classic Appserver 2. Properties and best practices
1. Tuning Tomcat Webserver 2. Choosing the right Connector
Scalability
1. Applying Load balancing for OpenEdge Applications 2. Stateless and Stateful Requests
© 2014 Progress Software Corporation. All rights reserved. 50
References
http://tomcat.apache.org/tomcat-7.0-doc/config/http.html
http://tomcatexpert.com/sites/default/files/PerformanceTuningApacheTomcat-Part2.pdf
http://tomcat.apache.org/connectors-doc/generic_howto/loadbalancers.html
© 2014 Progress Software Corporation. All rights reserved. 26
Want to Learn More About OpenEdge 11?
Role-based learning paths are available for OpenEdge 11
Each course is available as Instructor-led training or eLearning
Instructor-led training:
• $500 per student per day
• https://www.progress.com/support-and-services/education/instructor-led-training
eLearning:
• Via the Progress Education Community (https://wbt.progress.com):
• OpenEdge Developer Catalog: $1500 per user per year
• OpenEdge Administrator Catalog: $900 per user per year
User Assistance videos: https://www.progress.com/products/pacific/help/openedge
Get session details & presentation downloads Complete a survey Access the latest Progress product literature
www.progress.com/exchange2014
Visit the Resource Portal