Threads in PHP - will change the world

1,634 views
1,495 views

Published on

In August 2012 Joe Watkins introduced the Pthreads extension for PHP. Since then it is possible to use threads for asynchronous data handling in PHP as well. Now the extension is in a very promising state so it is definitely a look worth. The talk will show you the basics of using threads in PHP on the base of some real world examples. We will also have a look into interesting fields of future use. As parallelization and asynchronity is becoming more and more important this is a good way to step into some very interesting an promising fields.

Published in: Internet, Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,634
On SlideShare
0
From Embeds
0
Number of Embeds
629
Actions
Shares
0
Downloads
13
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Threads in PHP - will change the world

  1. 1. Threads in PHP „will changes the world“
  2. 2. Stefan Willkommer Co-Founder and CTO w agner_tim 78 @ Tim Wagner Co-Founder and Lead Architect @ sw illkom m er
  3. 3. Tiger Sissi me ;) Annette Uschi me ah Tim Barbecue
  4. 4. Let’s DIFFERENTIATE
  5. 5. EVENTLOOPS
  6. 6. FORKS
  7. 7. THREADS
  8. 8. What is a THREAD
  9. 9. Process-Model without THREADS
  10. 10. Process-Model with THREADS
  11. 11. What do we NEED
  12. 12. PHP 5.3+
  13. 13. compiled thread-safe --enable-maintainer-zts
  14. 14. PECL extension pthreads
  15. 15. my first THREAD
  16. 16. my first THREAD
  17. 17. What is a STACKABLE
  18. 18. enabling sharing and synchronizing Data over THREADS
  19. 19. tasks which can be processed by a WORKER
  20. 20. What can be SHARED
  21. 21. everything which is SERIALIZABLE
  22. 22. sharing Data with a Stackable
  23. 23. sharing Data with a Stackable
  24. 24. sharing Data with a Stackable
  25. 25. What is a WORKER
  26. 26. allows stacking of DATA
  27. 27. like a QUEUE
  28. 28. using a Worker
  29. 29. using a Worker
  30. 30. SYNCHRONISATION and CONCURRENCY HANDLING
  31. 31. waiting for Threads with join()
  32. 32. enables waiting for one or more THREADS
  33. 33. makes sure that result is available in THREAD
  34. 34. waiting by using Join
  35. 35. waiting by using Join
  36. 36. waiting by using Join
  37. 37. synchronizing Threads with synchronized()
  38. 38. synchronize with synchronized()
  39. 39. synchronize with synchronized()
  40. 40. synchronize with synchronized()
  41. 41. concurrency handling by using MUTEX
  42. 42. synchronize with Mutex
  43. 43. synchronize with Mutex
  44. 44. synchronize with Mutex
  45. 45. sharing Resources
  46. 46. sharing Sockets
  47. 47. sharing Sockets
  48. 48. sharing Sockets
  49. 49. What to do with all these POSSIBILITIES
  50. 50. GOOD everything is BAD
  51. 51. Runtime ApplicationServer PersistenceContainer Web MQ Objects WebServer Worker Threads Socket! 0.0.0.0:8587 Socket! 0.0.0.0:8585 Socket! 0.0.0.0:8586 HTTPRemoteMethodMessage Timer MBeans! SBeans! ! Worker
  52. 52. Performance comparison Test Profile Setup: 1 Webserver + 1 DB Server Virtualisation: KVM / Intel Xeon / 4 Cores OS: Debian wheezy Magento: 1.13.1.0 EE Amount of Products: 10,000 milliseconds 0 65 130 195 260 Homepage Category Page Detailpage AS, mod PHP nginx, PHP FPM
  53. 53. The power of MEMORY
  54. 54. Performance comparison Test Profile Setup: 1 Webserver + 1 DB Server Virtualisation: KVM / Intel Xeon / 4 Cores OS: Debian wheezy Magento: 1.13.1.0 EE Amount of Products: 10,000 milliseconds 0 65 130 195 260 Homepage Category Page Detailpage AS, Mage Servlet nginx, PHP FPM
  55. 55. 60% in average about faster
  56. 56. 280% in average about faster
  57. 57. What’s NEXT?
  58. 58. https://github.com/techdivision/phptek_2014 https://github.com/krakjoe/pthreads https://computing.llnl.gov/tutorials/pthreads/ http://appserver.io https://github.com/techdivision/TechDivision_ApplicationServer Ressources
  59. 59. Thank you! Questions?

×