Services
Dave McCrory         @mccrory on TwitterSenior Architect, Cloud Foundry, VMware
Wordpress?
Facebook apps on Heroku: 34,000 in 24 Hours                          How To:curl
‐u
“$EMAIL:$PASSWORD”
‐X
POST
https://api...
PaaS Provider   Your App                MySQL
1PaaS Provider       Your App                    MySQL
1PaaS Provider       Your App                2                    MySQL
1PaaS Provider       Your App                         3                2                    MySQL
Setting the Stage    “The Dream State”• This is specifically targeted at PaaS  (Platform as a Service)• All providers have ...
-Cobb
“...Inception, now before you bothertelling me its impossible...”                       -Cobb
-Eames
“No, its perfectly possible. Its justbloody difficult.”                        -Eames
Dependencies• Most Apps Have Them...• I’m not just talking about  • require ‘rubygems’  • Bundler  • etc...
I’m talking about Service Dependencies• “Assumes Redis”• “Built for MongoDB”• “Works with MySQL, other support  coming”• “...
YOU need to go setup       that Service...You need • Resources • the bits for the service (the correct version) • and YOU ...
An Example from Today
https://github.com/defunkt/resqueResque is our Redis-backed library for creatingbackground jobs, placing those jobs on mul...
https://github.com/defunkt/resqueResque is our Redis-backed library for creatingbackground jobs, placing those jobs on mul...
https://github.com/defunkt/resqueResque is our Redis-backed library for creatingbackground jobs, placing those jobs on mul...
https://github.com/wistia/resque-mongoResque-mongo is a fork of [Resque][resque] that usesMongoDB as a backend instead of ...
https://github.com/wistia/resque-mongoResque-mongo is a fork of [Resque][resque] that usesMongoDB as a backend instead of ...
https://github.com/wistia/resque-mongoResque-mongo is a fork of [Resque][resque] that usesMongoDB as a backend instead of ...
https://github.com/wistia/resque-mongoResque-mongo is a fork of [Resque][resque] that usesMongoDB as a backend instead of ...
https://github.com/wistia/resque-mongoResque-mongo is a fork of [Resque][resque] that usesMongoDB as a backend instead of ...
https://github.com/wistia/resque-mongoResque-mongo is a fork of [Resque][resque] that usesMongoDB as a backend instead of ...
-Eames
“If you’re going to perform inception,        you need imagination.”                               -Eames
Imagine an application   that can create theservices that it needs and      depends on...
Why do you need this?• Why does the Application have a  Dependency on a Service that you  have to create outside of your c...
Not meant to directly reflect resque-mongo       A Basic App                       App          $redis               $mongo...
Services Inception Services inside Services inside...              App                                      Depends on $re...
What happens if youforget or misconfigure a        Service?
Services Limbo -Cobb           “We drop into limbo.”                           “Are you serious?”                         ...
Why isn’t this part of the      code itself?
Services Inception• The App should ask the Platform for  the Service and get it• If the Platform doesn’t have a service  d...
We need a Services        Architect-Ariadne           “I designed the place.”
We need a Services           Architect   -Ariadne               “I designed the place.”  The original Developer of the cod...
PaaS Provider   Your App                MySQL
1PaaS Provider       Your App                    MySQL
1PaaS Provider       Your App                2                    MySQL
1PaaS Provider       Your App                         3                2                    MySQL
PaaS Provider   Your App                MySQL
1PaaS Provider       Your App                    MySQL
1PaaS Provider       Your App                2                    MySQL
1PaaS Provider       Your App                2                3   MySQL
1PaaS Provider       Your App                2        4                3   MySQL
PaaS Provider           App                Redis         MongoDB
PaaS Provider           App                Redis         MongoDB
PaaS Provider           App                Redis         MongoDB
PaaS Provider           App                Redis         MongoDB
One Approach
Planning Inception                                   manifest.yml



              App                                   ....
A Second Approach
DevOps?Maybe an extension or file format reuse?
A Third Approach
Why not do this in the              App                                          App code? $redis               $mongoconn...
configure
do

$client
=
Paasclient.new(MyPassword,nil)

resolve_deps
=
Dependency.new(DependsOn)end
Dependency.each
do
|dep_name,
dep_type|





case
dep_type





when
redis







unless
$client.exists(dep_name)








...
PaaS Provider           App                Redis         MongoDB
The Penrose Stairs     Be Careful withMetaprogramming Services
Methods• service exists / create / delete• service bound / bind / unbind• app exists / create / delete• app start / stop /...
A Sample More Complex     Application              Consuming App              (Uses Infrastructure Below)    Twitter      ...
Questions?    Opinions?Other Approaches?
Thank You!
Services inception in Ruby
Upcoming SlideShare
Loading in …5
×

Services inception in Ruby

6,323 views

Published on

Services Inception in Ruby, presented on Friday Sept. 30th @ RubyConf US 2011. Covering Metaprogramming and other options for building and consuming Cloud services from inside of Apps deployed to PaaS clouds.

Download from GitHub @ https://github.com/mccrory/ServicesInception-RubyConf-US-2011

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,323
On SlideShare
0
From Embeds
0
Number of Embeds
27
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Services inception in Ruby

    1. Services
    2. Dave McCrory @mccrory on TwitterSenior Architect, Cloud Foundry, VMware
    3. Wordpress?
    4. Facebook apps on Heroku: 34,000 in 24 Hours How To:curl
‐u
“$EMAIL:$PASSWORD”
‐X
POST
https://api.heroku.com/apps
    5. PaaS Provider Your App MySQL
    6. 1PaaS Provider Your App MySQL
    7. 1PaaS Provider Your App 2 MySQL
    8. 1PaaS Provider Your App 3 2 MySQL
    9. Setting the Stage “The Dream State”• This is specifically targeted at PaaS (Platform as a Service)• All providers have an interface (CLI or otherwise) to control services in their platform
    10. -Cobb
    11. “...Inception, now before you bothertelling me its impossible...” -Cobb
    12. -Eames
    13. “No, its perfectly possible. Its justbloody difficult.” -Eames
    14. Dependencies• Most Apps Have Them...• I’m not just talking about • require ‘rubygems’ • Bundler • etc...
    15. I’m talking about Service Dependencies• “Assumes Redis”• “Built for MongoDB”• “Works with MySQL, other support coming”• “Requires/Assumes X Service”
    16. YOU need to go setup that Service...You need • Resources • the bits for the service (the correct version) • and YOU must configure it • and in some cases you must install it
    17. An Example from Today
    18. https://github.com/defunkt/resqueResque is our Redis-backed library for creatingbackground jobs, placing those jobs on multiple queues,and processing them later.
    19. https://github.com/defunkt/resqueResque is our Redis-backed library for creatingbackground jobs, placing those jobs on multiple queues,and processing them later.Installing RedisResque requires Redis 0.900 or higher.
    20. https://github.com/defunkt/resqueResque is our Redis-backed library for creatingbackground jobs, placing those jobs on multiple queues,and processing them later.Installing RedisResque requires Redis 0.900 or higher.Resque Dependenciesgem install redis redis-namespace yajl-ruby
    21. https://github.com/wistia/resque-mongoResque-mongo is a fork of [Resque][resque] that usesMongoDB as a backend instead of Redis.
    22. https://github.com/wistia/resque-mongoResque-mongo is a fork of [Resque][resque] that usesMongoDB as a backend instead of Redis. Resque-mongo uses a fairly new feature of mongo, findAndModify(). findAndModify that is only supported by 0.20+ version ofthe ruby mongo driver.
    23. https://github.com/wistia/resque-mongoResque-mongo is a fork of [Resque][resque] that usesMongoDB as a backend instead of Redis. Resque-mongo uses a fairly new feature of mongo, findAndModify(). findAndModify that is only supported by 0.20+ version ofthe ruby mongo driver. Also, check your mongo version: 1.3.0 or higher
    24. https://github.com/wistia/resque-mongoResque-mongo is a fork of [Resque][resque] that usesMongoDB as a backend instead of Redis. Resque-mongo uses a fairly new feature of mongo, findAndModify(). findAndModify that is only supported by 0.20+ version ofthe ruby mongo driver. Also, check your mongo version: 1.3.0 or higher Mysql::Error:
MySQL
server
has
gone
away If your workers remain idle for too long they may lose their MySQL connection.
    25. https://github.com/wistia/resque-mongoResque-mongo is a fork of [Resque][resque] that usesMongoDB as a backend instead of Redis. Resque-mongo uses a fairly new feature of mongo, findAndModify(). findAndModify that is only supported by 0.20+ version ofthe ruby mongo driver. Also, check your mongo version: 1.3.0 or higher Mysql::Error:
MySQL
server
has
gone
away If your workers remain idle for too long they may lose their MySQL connection. Installing Redis Resque requires Redis 0.900 or higher.
    26. https://github.com/wistia/resque-mongoResque-mongo is a fork of [Resque][resque] that usesMongoDB as a backend instead of Redis. Resque-mongo uses a fairly new feature of mongo, findAndModify(). findAndModify that is only supported by 0.20+ version ofthe ruby mongo driver. Also, check your mongo version: 1.3.0 or higher Mysql::Error:
MySQL
server
has
gone
away If your workers remain idle for too long they may lose their MySQL connection. Installing Redis Resque requires Redis 0.900 or higher. Resque Dependencies gem install redis redis-namespace yajl-ruby
    27. -Eames
    28. “If you’re going to perform inception, you need imagination.” -Eames
    29. Imagine an application that can create theservices that it needs and depends on...
    30. Why do you need this?• Why does the Application have a Dependency on a Service that you have to create outside of your code?• Worse, replicate someone else’s steps/ configuration to get working properly?• Ideally you shouldn’t even have to find the resources they should build themselves!
    31. Not meant to directly reflect resque-mongo A Basic App App $redis $mongo connection connection Redis MongoDB PaaS
    32. Services Inception Services inside Services inside... App Depends on $redis $mongo Redis and Mongoconnection connection You are expected toRedis MongoDB set these up yourself using a command line PaaS tool in most cases
    33. What happens if youforget or misconfigure a Service?
    34. Services Limbo -Cobb “We drop into limbo.” “Are you serious?” -Arthur “Limbo?” “Unconstructed dream space.”-Ariadne
    35. Why isn’t this part of the code itself?
    36. Services Inception• The App should ask the Platform for the Service and get it• If the Platform doesn’t have a service due to complexity, the app should be able to create/build it• The App should have the ability to automatically bootstrap, update, and repair itself if need be• Include the steps, let me choose if I want to change them
    37. We need a Services Architect-Ariadne “I designed the place.”
    38. We need a Services Architect -Ariadne “I designed the place.” The original Developer of the code knows whatit expects, they should leave this behind with the code (either in it or as an artifact)
    39. PaaS Provider Your App MySQL
    40. 1PaaS Provider Your App MySQL
    41. 1PaaS Provider Your App 2 MySQL
    42. 1PaaS Provider Your App 3 2 MySQL
    43. PaaS Provider Your App MySQL
    44. 1PaaS Provider Your App MySQL
    45. 1PaaS Provider Your App 2 MySQL
    46. 1PaaS Provider Your App 2 3 MySQL
    47. 1PaaS Provider Your App 2 4 3 MySQL
    48. PaaS Provider App Redis MongoDB
    49. PaaS Provider App Redis MongoDB
    50. PaaS Provider App Redis MongoDB
    51. PaaS Provider App Redis MongoDB
    52. One Approach
    53. Planning Inception manifest.yml



 App .... $redis $mongoconnection connection services:
Redis MongoDB 





redis_test:
 PaaS 







type:
:redis 







if_exists:
keep 





mongo_test:
 







type:
:mongodb 







if_exists:
keep
    54. A Second Approach
    55. DevOps?Maybe an extension or file format reuse?
    56. A Third Approach
    57. Why not do this in the App App code? $redis $mongoconnection connectionRedis MongoDB PaaS DependsOn
=
{ 

foo
=>
redis,
 

bar
=>
mongo }
    58. configure
do

$client
=
Paasclient.new(MyPassword,nil)

resolve_deps
=
Dependency.new(DependsOn)end
    59. Dependency.each
do
|dep_name,
dep_type|





case
dep_type





when
redis







unless
$client.exists(dep_name)









$client.create_redis(dep_name)







end







unless
$client.bound(dep_name)









$client.bind(dep_name)







end





when
mongo







....
    60. PaaS Provider App Redis MongoDB
    61. The Penrose Stairs Be Careful withMetaprogramming Services
    62. Methods• service exists / create / delete• service bound / bind / unbind• app exists / create / delete• app start / stop / restart / instancesexisted? history?
    63. A Sample More Complex Application Consuming App (Uses Infrastructure Below) Twitter http service GridFS $redis $mongo connection connection Redis MongoDB Internet PaaS
    64. Questions? Opinions?Other Approaches?
    65. Thank You!

    ×