Apache Con NA 2013

423
-1

Published on

Published in: Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
423
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
7
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Apache Con NA 2013

  1. 1. Performance Optimizations for Apache Camel Christian Müller
  2. 2. WARNING: Jetlagged! http://sav-cdn.com/sites/default/files/imagecache/superphoto/10718770.jpg
  3. 3. Agenda ● Brief Introduction ● Content based routing EIP (and XML) ● Split EIP (and XML) ● Marshaling / Unmarshaling ● Working with files ● Accessing databases ● Working with threads() ● Working with templates ● Using Web Services ● Messaging ● Q&A
  4. 4. Brief introduction● 11 years of experience in software development and architecture – Focused on Java integration technologies● Senior Software Developer at Atos Worldline in Frankfurt, Germany – Tech. responsible for our integration platform based on ServiceMix & Camel● Apache Camel committer and current PMC chair – Partly involved in Apache Karaf, ServiceMix
  5. 5. Apache Camel 3.0● Be involved! – irc://irc.codehaus.org/camel – dev@camel.apache.org – http://camel.465427.n5.nabble.com/Camel- Development-f479097.html● Share your ideas & wishes with us! – http://camel.apache.org/camel-30-ideas.html● Be part of it! – http://camel.apache.org/camel-30-roadmap.html – http://camel.apache.org/contributing.html
  6. 6. Content based routing EIP● Demo
  7. 7. Content based routing EIP Duration in ms to route 10.000 10 KByte messages900080007000 XPath (JDK)6000 XPath (Saxon) XQuery5000 VTDXML* Simple Header4000300020001000 0 8900 4500 3900 2600 600 500 https://github.com/muellerc/apachecon-na-2013/tree/master/cbr-eip * GPL
  8. 8. Conclusion● Prefer to use conditions based on your message header● Use String contains check, if it works for you (e.g. with Simple language)● Use VDTXML if possible (GPL license)● Use XQuery● If you (have to) use XPath, make sure you have Saxon in your class path.
  9. 9. Split EIP● Demo
  10. 10. Split EIP Duration in ms to split a 100 MByte message Memory footprint in MByte to split a 100 MByte file9000800070006000 XPath (JDK) XPath (Saxon)5000 VTDXML* XML Tokenizer4000300020001000 0 0 8800 5100 7400 1126 480 200 8 https://github.com/muellerc/apachecon-na-2013/tree/master/split-eip * GPL
  11. 11. Conclusion● Use VDTXML if possible (GPL license)● Prefer to use the XML Tokenizer (NS limitation)● If you (have to) use XPath, make sure you have Saxon in your class path. – Otherwise there is a good chance it will fail
  12. 12. Marshaling / Unmarshaling● Demo
  13. 13. Marshaling / Unmarshaling Duration in ms to marshal and unmarshal 10.000 messages500045004000 XStream (XML)3500 XMLBeans (XML) JAXB (XML)3000 JIBX* (XML) XStream (Json)2500 Gson (Json) Jackson (Json)2000 Java Serialization15001000500 0 3100 2300 2200 1800 5000 1200 800 1100 https://github.com/muellerc/apachecon-na-2013/tree/master/marshaling-unmarshaling * doesnt work with Java 7 in every case
  14. 14. Conclusion● Use JIBX for XML if possible (not Java 7 ready at present)● Use JAXB for XML● Use Jackson for Json● Dont use Java serialization (not interoperable, not easy to read)
  15. 15. Working with files● Demo
  16. 16. Working with files Duration in ms to write 50.000 lines a 140 Bytes into a file18000160001400012000 Line by Line Aggregator (String) Aggregator (StringBuilder)10000 Streaming Aggregator (Build in)8000600040002000 0 14400 17700 4300 4300 3200 https://github.com/muellerc/apachecon-na-2013/tree/master/file-component
  17. 17. Conclusion● Use an Aggregator to reduce the number of file accesses (prefer the build in one)● Use a StringBuilder to concatenate Strings
  18. 18. Working with databases● Demo
  19. 19. Working with databases Duration in ms to insert 10.000 records350030002500 Record by Record Batched (by 10 records)2000 Batched (by 100 records) Batched (by 1000 records)15001000500 0 3200 1400 1200 1100 https://github.com/muellerc/apachecon-na-2013/tree/master/sql-component
  20. 20. Conclusion● Use an Aggregator to reduce the number of database accesses
  21. 21. Working with threads()● Demo
  22. 22. Working with threads() Duration in ms to process 1000 messages Duration in ms to process 10 files12000100008000 Single threaded processing Multi threaded processing (10)600040002000 0 11400 1200 10100 1100 https://github.com/muellerc/apachecon-na-2013/tree/master/threads
  23. 23. Conclusion● Use threads to parallelize your work
  24. 24. Working with templates● Demo
  25. 25. Working with templates Duration in ms to process 10000 messages350030002500 String Template Velocity2000 FreeMarker15001000500 0 3100 1200 1000 https://github.com/muellerc/apachecon-na-2013/tree/master/template
  26. 26. Conclusion● Prefer to use FreeMarker or Velocity
  27. 27. Using web services● Demo
  28. 28. Using web services Duration in ms to send 10000 messages300002500020000 POJO (without Woodstox) POJO PAYLOAD MESSAGE15000100005000 0 28300 26300 25400 23000 https://github.com/muellerc/apachecon-na-2013/tree/master/cxf-component
  29. 29. Conclusion● Prefer to use the PAYLOAD or MESSAGE data format if you dont need a Java object (skip the Unmarshaler)● Fine tune you container (Jetty, Tomcat, …) to use the right settings for your needs (connector, acceptor, ...)
  30. 30. Messaging● Demo
  31. 31. Messaging Duration in ms to process 100 messages600050004000 InOut perm. queue InOut temp. queue InOnly300020001000 0 5600 5600 1100 https://github.com/muellerc/apachecon-na-2013/tree/master/jms-component
  32. 32. Messaging Duration in ms to read and write 10000 messages350030002500 SJMS (Trans.) SJMS (Trans. Batch Consumer)2000 SJMS (Trans. Batch)*15001000500 0 3300 2500 2200 https://github.com/muellerc/apachecon-na-2013/tree/master/sjms-component * could be improved
  33. 33. Conclusion● Prefer to use InOnly routes instead of InOut routes if possible● Use temp. reply queues or exclusive perm. reply queues if you have to use InOut routes● Acknowledge messages in batch mode (SJMS)● Use the batch message to reduce the number of broker accesses (SJMS)
  34. 34. Q&A

×