Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Scaling with Swagger      Tony Tam      @fehguy
Scaling is the Developers JobWas:• Write code, make it work• If it get slow, buy: •   Bigger server •   Bigger database • ...
Needs Harmony Between• Software• Data Tier• Development Infrastructure• Deployment Infrastructure• Team• Ability to manage...
Needs Harmony Between• Software• Data Tier• Development Infrastructure• Deployment Infrastructure• Team• Ability to manage...
BackgroundBizTier Data Tier  DBA                     "Bee                       n
Common Mistakes…• "Lets organize by horizontal!"• "Back end shouldnt care what front end  does!"• "Just get it launched an...
Common Problems• Overly complicated interfaces •   Abstracted too many times •   "We can switch out entities with a simple...
Solutions• Many Possible •   Some suck, some good• Lets look at Wordnik
Directionally Speaking• Go Vertical! •   Ability to understand full lifecycle •   APIs as the communication of choice •   ...
Directionally Speaking• Go Vertical! •   Ability to understand full lifecycle •   APIs as the communication of choice •   ...
Vertical, Explained• Big application => micro servicesMonolithicapplication    "Isnt this       just     SOA?"
Not SOA• This is different  •   No proprietary message bus  •   Decoupled objects  •   Dedicated storage***• Speak REST  •...
Speak REST?• Sounds good but… •   REST semantics vary wildly •   HATEOAS vs. practical REST?/api/pet.json/1?delete (GET)/a...
Speak REST?• Sounds good but… •   REST semantics vary wildly •   HATEOAS vs. practical REST?/api/pet.json/1?delete (GET)  ...
Hello, Swagger• Swagger is… •   Spec for declaring an API schema •   A framework for auto-generating the spec •   A librar...
What is this Resource Declaration?• Listing of all available APIshttp://petstore.swagger.wordnik.com/api/resources.json   ...
What is this Resource Declaration?• “But I don’t want it all exposed!”  •   Swagger can filter APIs by permissions        ...
What is this Resource Declaration?• Each api is documentedhttp://petstore.swagger.wordnik.com/api/pet.json
API Documentation Highlights• Describes •   Operations •   Models• Permission-based filtering• JSON and XML supported
Anatomy of API Documentation
Anatomy of API Documentation                                Based on                                 JSON                 ...
API Parameters
API Parameters• Filtering on parameters• Enumerated options w/optional default
API Parameters
How does this help?• Generate client libs• Invoke methods not URLs• Pass arguments, not query params• Dont care about how ...
How does this help?• Generate client libs• Invoke methods not URLs• Pass arguments, not query params• DontRESTler? how ser...
Example Codegen./bin/generate-scala-lib.sh    http://petstore.swagger.wordnik.com/api    ""    "com.wordnik"    client
Example InvocationScala                        Ruby
But What about Speed?• Yes!   REST over HTTP is slow •   Connection overhead •   Marshaling & Unmarshaling overhead •   Ch...
But What about Speed?• Yes!   REST over HTTP is slow •   Connection overhead •                                 Your     Ma...
Websockets to the Rescue!• Its… •   Full Duplex •   Persistent connections •   Completely Async• But… •   Very finicky •  ...
Websockets to the Rescue!• Its… •   Full Duplex •   Persistent connections •   Completely Async• But… •   Very finicky •  ...
Abstracted by Atmospherehttps://github.com/Atmosphere/atmosphere• Fully Sponsored by Wordnik• Abstracts the mess• Support ...
Abstracted by Atmospherehttps://github.com/Atmosphere/atmosphere• Fully Sponsored by Wordnik• Abstracts the mess• Support ...
Swagger + Websockets• Swagger sockets •   Same discovery interface •   Same client interface •   Same codegen• But… •   Mu...
Swagger Sockets• Live now on smartmoney.com• Fully OSS• Wire-protocol speed• Format-agnostic •   JSON •   Binary
Summary• Smaller, dedicated units of work• Micro services => micro teams• Full service knowledge• Swagger is the Fabric fo...
See More…• http://swagger.wordnik.com/• https://github.com/wordnik/swagger-core• https://github.com/wordnik/swagger-ui• ht...
Questions?
Upcoming SlideShare
Loading in …5
×

Scaling with swagger

8,927 views

Published on

Ways you can scale your software and organization with Wordnik's Swagger framework

Published in: Technology
  • Be the first to comment

Scaling with swagger

  1. 1. Scaling with Swagger Tony Tam @fehguy
  2. 2. Scaling is the Developers JobWas:• Write code, make it work• If it get slow, buy: • Bigger server • Bigger database • "Enterprise" software support
  3. 3. Needs Harmony Between• Software• Data Tier• Development Infrastructure• Deployment Infrastructure• Team• Ability to manage it all
  4. 4. Needs Harmony Between• Software• Data Tier• Development Infrastructure• Deployment Infrastructure• Team• Ability to manage it Best Achieved all with Good Architecture
  5. 5. BackgroundBizTier Data Tier DBA "Bee n
  6. 6. Common Mistakes…• "Lets organize by horizontal!"• "Back end shouldnt care what front end does!"• "Just get it launched and well scale with hardware"• "You can scale transparently with technology X"• "Get an Oracle consultant to speed things up"
  7. 7. Common Problems• Overly complicated interfaces • Abstracted too many times • "We can switch out entities with a simple configuration!"• Over-abstracted • "We might need to change database vendors so abstract the SQL layer"• Over designed • "We dont know how the client will call, so support all possible calls!"
  8. 8. Solutions• Many Possible • Some suck, some good• Lets look at Wordnik
  9. 9. Directionally Speaking• Go Vertical! • Ability to understand full lifecycle • APIs as the communication of choice • General convergence on developers • Databases (MongoDB, Cassandra, Dynamo) • API frameworks• IT & QA are disappearing • Wordnik currently has *none* • Team, infrastructure, discipline *win*
  10. 10. Directionally Speaking• Go Vertical! • Ability to understand full lifecycle • APIs as the communication of choice • General convergence on developers Still Room • Databases (MongoDB, Cassandra, Dynamo) to specialize • API frameworks• IT & QA are disappearing • Wordnik currently has *none* • Team, infrastructure, discipline *win*
  11. 11. Vertical, Explained• Big application => micro servicesMonolithicapplication "Isnt this just SOA?"
  12. 12. Not SOA• This is different • No proprietary message bus • Decoupled objects • Dedicated storage***• Speak REST • Develop your services in… • Java • Scala • Ruby • Php
  13. 13. Speak REST?• Sounds good but… • REST semantics vary wildly • HATEOAS vs. practical REST?/api/pet.json/1?delete (GET)/api/pet.json/1 (DELETE) All/api/pet.json/1 (POST empty) valid!So…
  14. 14. Speak REST?• Sounds good but… • REST semantics vary wildly • HATEOAS vs. practical REST?/api/pet.json/1?delete (GET) Peer All/api/pet.json/1 (DELETE) Review! valid!/api/pet.json/1 (POST empty) Better Docs!So… API API Styleguide Council! !
  15. 15. Hello, Swagger• Swagger is… • Spec for declaring an API schema • A framework for auto-generating the spec • A library for client library generation • A JSON-based test framework
  16. 16. What is this Resource Declaration?• Listing of all available APIshttp://petstore.swagger.wordnik.com/api/resources.json “It’s like a sitemap for your API!”
  17. 17. What is this Resource Declaration?• “But I don’t want it all exposed!” • Swagger can filter APIs by permissions Header, Api key, URL, Cookies, Method OAuth
  18. 18. What is this Resource Declaration?• Each api is documentedhttp://petstore.swagger.wordnik.com/api/pet.json
  19. 19. API Documentation Highlights• Describes • Operations • Models• Permission-based filtering• JSON and XML supported
  20. 20. Anatomy of API Documentation
  21. 21. Anatomy of API Documentation Based on JSON Schema (Draft)http://tools.ietf.org/html/draft-zyp-json-schema-03
  22. 22. API Parameters
  23. 23. API Parameters• Filtering on parameters• Enumerated options w/optional default
  24. 24. API Parameters
  25. 25. How does this help?• Generate client libs• Invoke methods not URLs• Pass arguments, not query params• Dont care about how service is developed • Different versions of java? • Different REST frameworks?
  26. 26. How does this help?• Generate client libs• Invoke methods not URLs• Pass arguments, not query params• DontRESTler? how service is developed care about JAX-RS • Different versions of java? • Different REST frameworks? Client Play! Scalatra doesnt care
  27. 27. Example Codegen./bin/generate-scala-lib.sh http://petstore.swagger.wordnik.com/api "" "com.wordnik" client
  28. 28. Example InvocationScala Ruby
  29. 29. But What about Speed?• Yes! REST over HTTP is slow • Connection overhead • Marshaling & Unmarshaling overhead • Chatter • JSON/XML need to diet• Its also… • Synchronous • GET/POST/PUT/DELETE dont cut it
  30. 30. But What about Speed?• Yes! REST over HTTP is slow • Connection overhead • Your Marshaling & Unmarshaling overhead prod • Chatter Database • JSON/XML need to diet isnt doing• Its also… REST • Synchronous • GET/POST/PUT/DELETE dont cut it
  31. 31. Websockets to the Rescue!• Its… • Full Duplex • Persistent connections • Completely Async• But… • Very finicky • Wildly inconsistent server support • Still in draft
  32. 32. Websockets to the Rescue!• Its… • Full Duplex • Persistent connections • Completely Async• But… • Very finicky • Wildly inconsistent server support • Still in draft
  33. 33. Abstracted by Atmospherehttps://github.com/Atmosphere/atmosphere• Fully Sponsored by Wordnik• Abstracts the mess• Support on many containers• Client fallback/draft protocol support
  34. 34. Abstracted by Atmospherehttps://github.com/Atmosphere/atmosphere• Fully Sponsored by Wordnik• Abstracts the mess• Support on many containers• Client fallback/draft protocolTomcat support Weblogi Jetty c JBoss Resin Netty Glassfis h
  35. 35. Swagger + Websockets• Swagger sockets • Same discovery interface • Same client interface • Same codegen• But… • Multiplexed connections • Support for binary protocol • Full Async • Adding "subscribe" to GET/POST/PUT/DELETE
  36. 36. Swagger Sockets• Live now on smartmoney.com• Fully OSS• Wire-protocol speed• Format-agnostic • JSON • Binary
  37. 37. Summary• Smaller, dedicated units of work• Micro services => micro teams• Full service knowledge• Swagger is the Fabric for your Services• Swagger sockets are like Fiber for your grids connectivity
  38. 38. See More…• http://swagger.wordnik.com/• https://github.com/wordnik/swagger-core• https://github.com/wordnik/swagger-ui• https://github.com/wordnik/wordnik-oss
  39. 39. Questions?

×