Integrating Erlang with PHP

11,376 views
11,091 views

Published on

Talk for the conference at IPC Spring Edition 2010 - Berlin

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

No Downloads
Views
Total views
11,376
On SlideShare
0
From Embeds
0
Number of Embeds
154
Actions
Shares
0
Downloads
140
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Integrating Erlang with PHP

  1. 1. Integrating Erlang with PHP Alvaro Videla June 2010 - IPC Spring Edition - Berlin Wednesday, June 2, 2010
  2. 2. About Me • Lead Developer at TheNetCircle.com • Twitter: @old_sound • Blog: http://obvioushints.blogspot.com/ • PHP Erlang Bridge Core Developer Wednesday, June 2, 2010
  3. 3. What’s Erlang? Wednesday, June 2, 2010
  4. 4. What’s Erlang? • General Purpose Functional Language Wednesday, June 2, 2010
  5. 5. What’s Erlang? • General Purpose Functional Language • Multi Platform Wednesday, June 2, 2010
  6. 6. What’s Erlang? • General Purpose Functional Language • Multi Platform • Invented in 1986 at Ericsson Wednesday, June 2, 2010
  7. 7. What’s Erlang? • General Purpose Functional Language • Multi Platform • Invented in 1986 at Ericsson • Open Sourced in 1998 Wednesday, June 2, 2010
  8. 8. Products written in Erlang Wednesday, June 2, 2010
  9. 9. Products written in Erlang • Amazon SimpleDB Wednesday, June 2, 2010
  10. 10. Products written in Erlang • Amazon SimpleDB • Ejabberd - XMPP server Wednesday, June 2, 2010
  11. 11. Products written in Erlang • Amazon SimpleDB • Ejabberd - XMPP server • RabbitMQ - AMQP Messaging Server Wednesday, June 2, 2010
  12. 12. Products written in Erlang • Amazon SimpleDB • Ejabberd - XMPP server • RabbitMQ - AMQP Messaging Server • Riak - Decentralized Key/Value Store Wednesday, June 2, 2010
  13. 13. Products written in Erlang • Amazon SimpleDB • Ejabberd - XMPP server • RabbitMQ - AMQP Messaging Server • Riak - Decentralized Key/Value Store • CouchDB - Document Oriented Database Wednesday, June 2, 2010
  14. 14. Products written in Erlang • Amazon SimpleDB • Ejabberd - XMPP server • RabbitMQ - AMQP Messaging Server • Riak - Decentralized Key/Value Store • CouchDB - Document Oriented Database • Mochiweb - Lightweight HTTP Servers Wednesday, June 2, 2010
  15. 15. What’s in the package? Wednesday, June 2, 2010
  16. 16. What’s in the package? • Fault Tolerance Wednesday, June 2, 2010
  17. 17. What’s in the package? • Fault Tolerance • Distribution Wednesday, June 2, 2010
  18. 18. What’s in the package? • Fault Tolerance • Distribution • Concurrency Wednesday, June 2, 2010
  19. 19. What’s in the package? • Fault Tolerance • Distribution • Concurrency • Code Hot Swap Wednesday, June 2, 2010
  20. 20. What’s in the package? • Fault Tolerance • Distribution • Concurrency • Code Hot Swap • Mnesia a DDBMS Wednesday, June 2, 2010
  21. 21. What’s in the package? • Fault Tolerance • Distribution • Concurrency • Code Hot Swap • Mnesia a DDBMS • OTP Framework Wednesday, June 2, 2010
  22. 22. The Language • Single Assignment Wednesday, June 2, 2010
  23. 23. The Language • Single Assignment • Controlled Side Effects Wednesday, June 2, 2010
  24. 24. The Language • Single Assignment • Controlled Side Effects • Pattern Matching Wednesday, June 2, 2010
  25. 25. The Language • Single Assignment • Controlled Side Effects • Pattern Matching • Closures Wednesday, June 2, 2010
  26. 26. PHP Integration • PHP Erlang Bridge • C Extension • Converts PHP into a “cnode” Wednesday, June 2, 2010
  27. 27. What can I build? Wednesday, June 2, 2010
  28. 28. What can I build? • Web Admins for Erlang Systems Wednesday, June 2, 2010
  29. 29. What can I build? • Web Admins for Erlang Systems • PHP Session Storage Systems Wednesday, June 2, 2010
  30. 30. What can I build? • Web Admins for Erlang Systems • PHP Session Storage Systems • Ad hoc K/V stores Wednesday, June 2, 2010
  31. 31. What can I build? • Web Admins for Erlang Systems • PHP Session Storage Systems • Ad hoc K/V stores • Run Map/Reduce Jobs in Erlang Wednesday, June 2, 2010
  32. 32. What can I build? • Web Admins for Erlang Systems • PHP Session Storage Systems • Ad hoc K/V stores • Run Map/Reduce Jobs in Erlang • Much more… Wednesday, June 2, 2010
  33. 33. RabbitMQ Admin Console Wednesday, June 2, 2010
  34. 34. RabbitMQ Admin Console Wednesday, June 2, 2010
  35. 35. RabbitMQ Admin Console Wednesday, June 2, 2010
  36. 36. RabbitMQ Admin Console Wednesday, June 2, 2010
  37. 37. Session Storage • Why? • To ease session data distribution • Be able to add logic to sessions • Several storage backends to choose from Wednesday, June 2, 2010
  38. 38. Session Storage: Bitcask • Developed by Basho as a Riak backend • Minimalistic API • Stores data on disk • Easy to Backup and Restore * http://blog.basho.com/2010/04/27/hello,-bitcask/ Wednesday, June 2, 2010
  39. 39. Session Storage: Bitcask http://github.com/videlalvaro/phpcask Wednesday, June 2, 2010
  40. 40. Session Storage: Bitcask Wednesday, June 2, 2010
  41. 41. Session Storage: Bitcask Wednesday, June 2, 2010
  42. 42. Session Storage: Bitcask Wednesday, June 2, 2010
  43. 43. Session Storage: Bitcask Wednesday, June 2, 2010
  44. 44. Ad Hoc K/V Store • Using Erlang Term Storage (ETS) • In memory tables • Adapt the API to suit your needs Wednesday, June 2, 2010
  45. 45. Do I have to learn Erlang? Wednesday, June 2, 2010
  46. 46. Do I have to learn Erlang? • NO Wednesday, June 2, 2010
  47. 47. Do I have to learn Erlang? • NO • Well,Yes, a little will help. Wednesday, June 2, 2010
  48. 48. Do I have to learn Erlang? http://learnyousomeerlang.com/ Wednesday, June 2, 2010
  49. 49. Installing the extension • grab the code* • phpize • ./configure • make • make install * http://code.google.com/p/mypeb/ Wednesday, June 2, 2010
  50. 50. Hello Erlang Wednesday, June 2, 2010
  51. 51. Hello Erlang Wednesday, June 2, 2010
  52. 52. Connecting to erlang • peb_connect($host, $cookie); Wednesday, June 2, 2010
  53. 53. Sending messages • peb_send_by_name($node, $msg, $link); • peb_send_by_pid($node, $msg, $link); Wednesday, June 2, 2010
  54. 54. Encoding messages • peb_vencode($format, $data); • peb_encode($format, $data); Wednesday, June 2, 2010
  55. 55. Encoding Examples Wednesday, June 2, 2010
  56. 56. Formatting Characters • [] List • {} Tuple • ~a Atom • ~s String • ~b Binary • ~i Integer • ~d Double • ~p Pid Wednesday, June 2, 2010
  57. 57. Receiving Messages • peb_receive($link); Wednesday, June 2, 2010
  58. 58. Decoding Messages • peb_vdecode($msg); • peb_decode($msg); Wednesday, June 2, 2010
  59. 59. Decoding Messages • String, Atom, Binary -> String • Tuple, List -> Array • Pid -> Resource • Integer -> Integer • Float -> Double Wednesday, June 2, 2010
  60. 60. RPC Calls • peb_rpc($node, $module, $function, $msg); • peb_rpc_to($node, $module, $function, $msg); Wednesday, June 2, 2010
  61. 61. Resources • PHP Erlang Bridge: http://code.google.com/p/mypeb/ • Erlang Website: http://www.erlang.org/ • Online Book: http://learnyousomeerlang.com/ • Community Site http://trapexit.org/ • Conferences: http://www.erlang-factory.com/ Wednesday, June 2, 2010
  62. 62. Questions? Wednesday, June 2, 2010
  63. 63. Thanks! Alvaro Videla http://twitter.com/old_sound TheNetCircle.com Wednesday, June 2, 2010

×