SlideShare a Scribd company logo
Tomcat 6: Evolving our service Preface Debugging Valves Apache WS + Tomcat Load Balancing Clustering Monitoring
Introducing our project Mobile based online marketing project J2EE technology: scalable and robust. To serve applications we need Tomcat. Ubuntu server under three enviroments: develop, preproduction and production. Servers with external provider. Mobile Web and Proxy in the same app.
Architecture Web Proxy Backend MySQL Tomcat Server Client Server Shared Database Server
Challenge: Testing integration Qustodian Backend needs a fixed URL to connect. We develop the project with IDE and debugger.  We can't emulate client conection to our system. Conclusion: Dificult to locally debug.
Solution: Remote debugging Tomcat has a connector that allows to debugger to plug in to the server. Using Java Platform Debugger Architecture (JDPA)and Java Debug Wire Protocol (JDWP) Configuring Tomcat in catalina.sh to start in debug mode adding to CATALINA_OPTS variable with export. Another script to invoke Tomcat with this options to avoid editing everytime. -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000
Remote debugging In  NetBeans  you can start remote debugger in these buttons: And configure it with:
Challenge: Following server request Service starts being bigger. Mobile applications connects to Proxy REST API. Backend request to Proxy. Is a good practice to follow users activity. In Apache Web Server we have an access log. Easy to detect bad requests or attacks.
Previous concept: Valves Valves are Tomcat components which is inserted into request processing pipeline for the associated Catalina container. Several applications in Tomcat: Access Log Remote Address or Host Filter Authentication More ...
Solution: AccessLogValve We only need to uncomment in  server.xml  the line: <Valve className=&quot;org.apache.catalina.valves.AccessLogValve&quot; directory=&quot;logs&quot; prefix=&quot;localhost_access_log.&quot; suffix=&quot;.txt&quot; pattern=&quot;common&quot; resolveHosts=&quot;false&quot;/> The common pattern show log entries in this way: REMOTE_HOST - REMOTE_USER DATETIME &quot;REQUEST_FIRST_LINE&quot; HTTP_STATUS_CODE BYTES_SENT There are others log patterns and options to configure, as conditional logging can be found here .
Access Log applications There are many software handling the access log to show it in graphical mode improving its analysis. Some examples are: http://www.weblogexpert.com/ http://www.hping.org/visitors/
Challenge: Hide pass in request Mobile clients make the request to login. Avoid storing passwords in the log file. Hide password string from request under * characters. http://m.server.com/api/users/login?pass= **** &device_platform=200
Solution: Extending LogValve
Challenge: Better performance In our service, user activity started growing soon. We had a main critical operation: publishing campaigns to users. Campaigns to 4000 users approx. Too many connections: threads in heap memory and DB connections
Solution: Improve server We asked for RAM memory Updated OpenJDK to last Oracle JVM. Updated the Apache Tomcat version Modified Tomcat start with new memory params
Challenge: High Availability Shorten deployment time in production. Minimize impact of server down to users.
Solution: Load Balancing High Availability performance and scalability. Ask for two or more nodes with Tomcat. Apache Web Server as balancer component. Mantain session persistence across the nodes
Apache and Tomcat Apache Web Server redirecting traffic to nodes. Apache schedule the request with  algorithms. Sticky sessions  as solution to avoid session lost. Using  mod_jk  or  mod_proxy  connectors.
Apache as balancer with mod_proxy Copy the modules to mods-enabled directory proxy_ajp.load  -> ../mods-available/proxy_ajp.load proxy.load  -> ../mods-available/proxy.load proxy.conf  -> ../mods-available/proxy.conf proxy_balancer.load -> ../mods-available/proxy_balancer.load Configure proxy_balancer.conf <Proxy balancer://mycluster> BalancerMember http://192.168.1.50:8080 BalancerMember http://192.168.1.51:8080 </Proxy> ProxyPass /test balancer://mycluster
BrightBox has a balancer BrightBox  provides a  Load Balancer  highly configurable with limitations: Depends on IP:PORT Least Connection : scheduler which means connections are allocated to the server with the least number of connections 5 min  Sticky Session Server can not access to balancer IP We have a fast solution and more problems ...
Architecture Web Proxy Backend MySQL Tomcat Server Client Server Database Server Web Proxy Tomcat Server Web Proxy Tomcat Server B 2 1 Balancer
Challenge:Keeping session Mobiles usually changes IP each request, so we lose session. If server goes down, you need to login again in other.
Solution: Session Replication Session replication in Tomcat cluster. Two algorithm: SimpleTcpReplicationManager DeltaManager Communication over: IP Multicast  IP Sockets Session-state persistence: In memory (SimpleTcpCluster) Database persistence (JDBCManager) File-based persistence (PersistenceManager)
IP Sockets in-memory replication Application must be “ distributable ” in web.xml Stored objects in session must be  serializable . All session attributes are replicated  for each HTTP Request Valves to  filter  the replication.
Architecture Web Proxy Backend MySQL Tomcat Server Client Server Database Server Web Proxy Tomcat Server Web Proxy Tomcat Server B 2 1 Balancer Session  Replication
Challenge: Monitoring Tomcat Server activity Show request time Watch server load Alerts if server goes down
Solution:Three services Monit  – installed in server, to trigger actions under conditions NewRelic  – installed in tomcat, to monitoring application and server memory, request … Pingdom  – installed in iPhone, service that alerts you if server goes down.
Pingdom
Question time

More Related Content

PDF
How to monitor and manage Apache Tomcat
PPT
Tomcat Clustering
PPT
Auxiliary : Tomcat
PPT
Tomcat Configuration (1)
PPT
Tomcat Server
PDF
Introduction to Apache Tomcat 7 Presentation
PPTX
Introduction of Tomcat
PDF
Apache Tomcat 8 Application Server
How to monitor and manage Apache Tomcat
Tomcat Clustering
Auxiliary : Tomcat
Tomcat Configuration (1)
Tomcat Server
Introduction to Apache Tomcat 7 Presentation
Introduction of Tomcat
Apache Tomcat 8 Application Server

What's hot (19)

PPT
Tomcat server
PDF
Tomcat next
PPT
PPTX
Hybris server-internals
PPTX
Web container and Apache Tomcat
PPTX
Apache tomcat
PPT
Tomcat configuration
PDF
Pandora FMS: Tomcat Monitoring
PDF
Apache Tomcat + Java EE = Apache TomEE
PPT
Apache Tomcat 7 by Filip Hanik
PDF
Tomcat and apache httpd training
PPTX
introduction to Tomcat Apache
DOCX
Integrating tomcat with apache
PPT
Java Servlets
PPT
Mule - logger
PDF
Weblogic monitoring
PDF
Servlet
PDF
Magento 2.2: It's Coming Right For You! | Colorado Magento Meetup
Tomcat server
Tomcat next
Hybris server-internals
Web container and Apache Tomcat
Apache tomcat
Tomcat configuration
Pandora FMS: Tomcat Monitoring
Apache Tomcat + Java EE = Apache TomEE
Apache Tomcat 7 by Filip Hanik
Tomcat and apache httpd training
introduction to Tomcat Apache
Integrating tomcat with apache
Java Servlets
Mule - logger
Weblogic monitoring
Servlet
Magento 2.2: It's Coming Right For You! | Colorado Magento Meetup
Ad

Similar to Tomcat 6: Evolving our server (20)

PPT
Web Server/App Server Connectivity
PDF
Webapplication Load Balancing
PDF
Apache httpd Reverse Proxy and Tomcat
PDF
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
PDF
Fixing twitter
PDF
Fixing_Twitter
PDF
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
PDF
Apache httpd 2.4 Reverse Proxy: The Hidden Gem
PPTX
Apache Performance Tuning: Scaling Out
PDF
Scalable Architecture 101
PDF
Apache HTTPD 2.4 Reverse Proxy: The Hidden Gem
PDF
Hatohol technical-brief-20130830-hbstudy
PDF
PyCon 2011 Scaling Disqus
PDF
John adams talk cloudy
KEY
Fixing Twitter Velocity2009
PDF
Pervasive Web Application Architecture
PDF
zingmepracticeforbuildingscalablewebsitewithphp
PDF
Zingme practice for building scalable website with PHP
PDF
01 zingme practice for building scalable website with php
PDF
Zingme practice for building scalable website with PHP
Web Server/App Server Connectivity
Webapplication Load Balancing
Apache httpd Reverse Proxy and Tomcat
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Fixing twitter
Fixing_Twitter
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Apache httpd 2.4 Reverse Proxy: The Hidden Gem
Apache Performance Tuning: Scaling Out
Scalable Architecture 101
Apache HTTPD 2.4 Reverse Proxy: The Hidden Gem
Hatohol technical-brief-20130830-hbstudy
PyCon 2011 Scaling Disqus
John adams talk cloudy
Fixing Twitter Velocity2009
Pervasive Web Application Architecture
zingmepracticeforbuildingscalablewebsitewithphp
Zingme practice for building scalable website with PHP
01 zingme practice for building scalable website with php
Zingme practice for building scalable website with PHP
Ad

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
KodekX | Application Modernization Development
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Encapsulation theory and applications.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Big Data Technologies - Introduction.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
A Presentation on Artificial Intelligence
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
KodekX | Application Modernization Development
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Dropbox Q2 2025 Financial Results & Investor Presentation
Review of recent advances in non-invasive hemoglobin estimation
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Encapsulation theory and applications.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Digital-Transformation-Roadmap-for-Companies.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Big Data Technologies - Introduction.pptx
MYSQL Presentation for SQL database connectivity
Encapsulation_ Review paper, used for researhc scholars
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...
Unlocking AI with Model Context Protocol (MCP)
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
A Presentation on Artificial Intelligence

Tomcat 6: Evolving our server

  • 1. Tomcat 6: Evolving our service Preface Debugging Valves Apache WS + Tomcat Load Balancing Clustering Monitoring
  • 2. Introducing our project Mobile based online marketing project J2EE technology: scalable and robust. To serve applications we need Tomcat. Ubuntu server under three enviroments: develop, preproduction and production. Servers with external provider. Mobile Web and Proxy in the same app.
  • 3. Architecture Web Proxy Backend MySQL Tomcat Server Client Server Shared Database Server
  • 4. Challenge: Testing integration Qustodian Backend needs a fixed URL to connect. We develop the project with IDE and debugger. We can't emulate client conection to our system. Conclusion: Dificult to locally debug.
  • 5. Solution: Remote debugging Tomcat has a connector that allows to debugger to plug in to the server. Using Java Platform Debugger Architecture (JDPA)and Java Debug Wire Protocol (JDWP) Configuring Tomcat in catalina.sh to start in debug mode adding to CATALINA_OPTS variable with export. Another script to invoke Tomcat with this options to avoid editing everytime. -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000
  • 6. Remote debugging In NetBeans you can start remote debugger in these buttons: And configure it with:
  • 7. Challenge: Following server request Service starts being bigger. Mobile applications connects to Proxy REST API. Backend request to Proxy. Is a good practice to follow users activity. In Apache Web Server we have an access log. Easy to detect bad requests or attacks.
  • 8. Previous concept: Valves Valves are Tomcat components which is inserted into request processing pipeline for the associated Catalina container. Several applications in Tomcat: Access Log Remote Address or Host Filter Authentication More ...
  • 9. Solution: AccessLogValve We only need to uncomment in server.xml the line: <Valve className=&quot;org.apache.catalina.valves.AccessLogValve&quot; directory=&quot;logs&quot; prefix=&quot;localhost_access_log.&quot; suffix=&quot;.txt&quot; pattern=&quot;common&quot; resolveHosts=&quot;false&quot;/> The common pattern show log entries in this way: REMOTE_HOST - REMOTE_USER DATETIME &quot;REQUEST_FIRST_LINE&quot; HTTP_STATUS_CODE BYTES_SENT There are others log patterns and options to configure, as conditional logging can be found here .
  • 10. Access Log applications There are many software handling the access log to show it in graphical mode improving its analysis. Some examples are: http://www.weblogexpert.com/ http://www.hping.org/visitors/
  • 11. Challenge: Hide pass in request Mobile clients make the request to login. Avoid storing passwords in the log file. Hide password string from request under * characters. http://m.server.com/api/users/login?pass= **** &device_platform=200
  • 13. Challenge: Better performance In our service, user activity started growing soon. We had a main critical operation: publishing campaigns to users. Campaigns to 4000 users approx. Too many connections: threads in heap memory and DB connections
  • 14. Solution: Improve server We asked for RAM memory Updated OpenJDK to last Oracle JVM. Updated the Apache Tomcat version Modified Tomcat start with new memory params
  • 15. Challenge: High Availability Shorten deployment time in production. Minimize impact of server down to users.
  • 16. Solution: Load Balancing High Availability performance and scalability. Ask for two or more nodes with Tomcat. Apache Web Server as balancer component. Mantain session persistence across the nodes
  • 17. Apache and Tomcat Apache Web Server redirecting traffic to nodes. Apache schedule the request with algorithms. Sticky sessions as solution to avoid session lost. Using mod_jk or mod_proxy connectors.
  • 18. Apache as balancer with mod_proxy Copy the modules to mods-enabled directory proxy_ajp.load -> ../mods-available/proxy_ajp.load proxy.load -> ../mods-available/proxy.load proxy.conf -> ../mods-available/proxy.conf proxy_balancer.load -> ../mods-available/proxy_balancer.load Configure proxy_balancer.conf <Proxy balancer://mycluster> BalancerMember http://192.168.1.50:8080 BalancerMember http://192.168.1.51:8080 </Proxy> ProxyPass /test balancer://mycluster
  • 19. BrightBox has a balancer BrightBox provides a Load Balancer highly configurable with limitations: Depends on IP:PORT Least Connection : scheduler which means connections are allocated to the server with the least number of connections 5 min Sticky Session Server can not access to balancer IP We have a fast solution and more problems ...
  • 20. Architecture Web Proxy Backend MySQL Tomcat Server Client Server Database Server Web Proxy Tomcat Server Web Proxy Tomcat Server B 2 1 Balancer
  • 21. Challenge:Keeping session Mobiles usually changes IP each request, so we lose session. If server goes down, you need to login again in other.
  • 22. Solution: Session Replication Session replication in Tomcat cluster. Two algorithm: SimpleTcpReplicationManager DeltaManager Communication over: IP Multicast IP Sockets Session-state persistence: In memory (SimpleTcpCluster) Database persistence (JDBCManager) File-based persistence (PersistenceManager)
  • 23. IP Sockets in-memory replication Application must be “ distributable ” in web.xml Stored objects in session must be serializable . All session attributes are replicated for each HTTP Request Valves to filter the replication.
  • 24. Architecture Web Proxy Backend MySQL Tomcat Server Client Server Database Server Web Proxy Tomcat Server Web Proxy Tomcat Server B 2 1 Balancer Session Replication
  • 25. Challenge: Monitoring Tomcat Server activity Show request time Watch server load Alerts if server goes down
  • 26. Solution:Three services Monit – installed in server, to trigger actions under conditions NewRelic – installed in tomcat, to monitoring application and server memory, request … Pingdom – installed in iPhone, service that alerts you if server goes down.