Your SlideShare is downloading. ×
Tomcat 6: Evolving our server
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Tomcat 6: Evolving our server

2,637
views

Published on

Elecnor Deimos Tomcat 6 slideshare …

Elecnor Deimos Tomcat 6 slideshare
Debugging
Valves
Apache
Load Balancing
Clustering
Monitoring

Published in: Technology

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,637
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 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.qustodian.com/api/users/login?pass= **** &device_platform=200
  • 12. Solution: Extending LogValve
  • 13. Challenge: Better performance
    • In Qustodian, 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.
  • 27. Pingdom
  • 28. Question time