Integrating Erlang with PHP

  • 9,335 views
Uploaded on

Talk for the conference at IPC Spring Edition 2010 - Berlin

Talk for the conference at IPC Spring Edition 2010 - Berlin

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
9,335
On Slideshare
0
From Embeds
0
Number of Embeds
5

Actions

Shares
Downloads
112
Comments
0
Likes
5

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. Integrating Erlang with PHP Alvaro Videla June 2010 - IPC Spring Edition - Berlin Wednesday, June 2, 2010
  • 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. What’s Erlang? Wednesday, June 2, 2010
  • 4. What’s Erlang? • General Purpose Functional Language Wednesday, June 2, 2010
  • 5. What’s Erlang? • General Purpose Functional Language • Multi Platform Wednesday, June 2, 2010
  • 6. What’s Erlang? • General Purpose Functional Language • Multi Platform • Invented in 1986 at Ericsson Wednesday, June 2, 2010
  • 7. What’s Erlang? • General Purpose Functional Language • Multi Platform • Invented in 1986 at Ericsson • Open Sourced in 1998 Wednesday, June 2, 2010
  • 8. Products written in Erlang Wednesday, June 2, 2010
  • 9. Products written in Erlang • Amazon SimpleDB Wednesday, June 2, 2010
  • 10. Products written in Erlang • Amazon SimpleDB • Ejabberd - XMPP server Wednesday, June 2, 2010
  • 11. Products written in Erlang • Amazon SimpleDB • Ejabberd - XMPP server • RabbitMQ - AMQP Messaging Server Wednesday, June 2, 2010
  • 12. Products written in Erlang • Amazon SimpleDB • Ejabberd - XMPP server • RabbitMQ - AMQP Messaging Server • Riak - Decentralized Key/Value Store Wednesday, June 2, 2010
  • 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. 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. What’s in the package? Wednesday, June 2, 2010
  • 16. What’s in the package? • Fault Tolerance Wednesday, June 2, 2010
  • 17. What’s in the package? • Fault Tolerance • Distribution Wednesday, June 2, 2010
  • 18. What’s in the package? • Fault Tolerance • Distribution • Concurrency Wednesday, June 2, 2010
  • 19. What’s in the package? • Fault Tolerance • Distribution • Concurrency • Code Hot Swap Wednesday, June 2, 2010
  • 20. What’s in the package? • Fault Tolerance • Distribution • Concurrency • Code Hot Swap • Mnesia a DDBMS Wednesday, June 2, 2010
  • 21. What’s in the package? • Fault Tolerance • Distribution • Concurrency • Code Hot Swap • Mnesia a DDBMS • OTP Framework Wednesday, June 2, 2010
  • 22. The Language • Single Assignment Wednesday, June 2, 2010
  • 23. The Language • Single Assignment • Controlled Side Effects Wednesday, June 2, 2010
  • 24. The Language • Single Assignment • Controlled Side Effects • Pattern Matching Wednesday, June 2, 2010
  • 25. The Language • Single Assignment • Controlled Side Effects • Pattern Matching • Closures Wednesday, June 2, 2010
  • 26. PHP Integration • PHP Erlang Bridge • C Extension • Converts PHP into a “cnode” Wednesday, June 2, 2010
  • 27. What can I build? Wednesday, June 2, 2010
  • 28. What can I build? • Web Admins for Erlang Systems Wednesday, June 2, 2010
  • 29. What can I build? • Web Admins for Erlang Systems • PHP Session Storage Systems Wednesday, June 2, 2010
  • 30. What can I build? • Web Admins for Erlang Systems • PHP Session Storage Systems • Ad hoc K/V stores Wednesday, June 2, 2010
  • 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. 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. RabbitMQ Admin Console Wednesday, June 2, 2010
  • 34. RabbitMQ Admin Console Wednesday, June 2, 2010
  • 35. RabbitMQ Admin Console Wednesday, June 2, 2010
  • 36. RabbitMQ Admin Console Wednesday, June 2, 2010
  • 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. 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. Session Storage: Bitcask http://github.com/videlalvaro/phpcask Wednesday, June 2, 2010
  • 40. Session Storage: Bitcask Wednesday, June 2, 2010
  • 41. Session Storage: Bitcask Wednesday, June 2, 2010
  • 42. Session Storage: Bitcask Wednesday, June 2, 2010
  • 43. Session Storage: Bitcask Wednesday, June 2, 2010
  • 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. Do I have to learn Erlang? Wednesday, June 2, 2010
  • 46. Do I have to learn Erlang? • NO Wednesday, June 2, 2010
  • 47. Do I have to learn Erlang? • NO • Well,Yes, a little will help. Wednesday, June 2, 2010
  • 48. Do I have to learn Erlang? http://learnyousomeerlang.com/ Wednesday, June 2, 2010
  • 49. Installing the extension • grab the code* • phpize • ./configure • make • make install * http://code.google.com/p/mypeb/ Wednesday, June 2, 2010
  • 50. Hello Erlang Wednesday, June 2, 2010
  • 51. Hello Erlang Wednesday, June 2, 2010
  • 52. Connecting to erlang • peb_connect($host, $cookie); Wednesday, June 2, 2010
  • 53. Sending messages • peb_send_by_name($node, $msg, $link); • peb_send_by_pid($node, $msg, $link); Wednesday, June 2, 2010
  • 54. Encoding messages • peb_vencode($format, $data); • peb_encode($format, $data); Wednesday, June 2, 2010
  • 55. Encoding Examples Wednesday, June 2, 2010
  • 56. Formatting Characters • [] List • {} Tuple • ~a Atom • ~s String • ~b Binary • ~i Integer • ~d Double • ~p Pid Wednesday, June 2, 2010
  • 57. Receiving Messages • peb_receive($link); Wednesday, June 2, 2010
  • 58. Decoding Messages • peb_vdecode($msg); • peb_decode($msg); Wednesday, June 2, 2010
  • 59. Decoding Messages • String, Atom, Binary -> String • Tuple, List -> Array • Pid -> Resource • Integer -> Integer • Float -> Double Wednesday, June 2, 2010
  • 60. RPC Calls • peb_rpc($node, $module, $function, $msg); • peb_rpc_to($node, $module, $function, $msg); Wednesday, June 2, 2010
  • 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. Questions? Wednesday, June 2, 2010
  • 63. Thanks! Alvaro Videla http://twitter.com/old_sound TheNetCircle.com Wednesday, June 2, 2010