Server Connect To API / 3rd Service Pattern

  • 213 views
Uploaded on

when node.js as a middle server and connect to other servers, what should you notice? what do you have to ready after building a node.js process? …

when node.js as a middle server and connect to other servers, what should you notice? what do you have to ready after building a node.js process?

We discuss the infrastructures and node.js processing that we have to know.

More in: Technology
  • 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
213
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
0
Comments
0
Likes
7

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. Server Connect To API / 3rd Service Pattern Caesar Chi @clonncd Node.js 與多方服務串接實務 Monday, June 23, 14
  • 2. @clonncd Monday, June 23, 14
  • 3. Monday, June 23, 14
  • 4. https://github.com/nodejs-tw/nodejs-wiki-book Monday, June 23, 14
  • 5. Monday, June 23, 14
  • 6. Structure Clients Server Monday, June 23, 14
  • 7. That means we thought done with something in Node.js But actually we did nothing special. Monday, June 23, 14
  • 8. Monday, June 23, 14
  • 9. Request of As a Front end Server Monday, June 23, 14
  • 10. Structure front Server Services secret information cache send Request Monday, June 23, 14
  • 11. WWW are APIs When Node.js has Request Monday, June 23, 14
  • 12. Structure front Server Services send Request ... ... Monday, June 23, 14
  • 13. But When Service requirement Grows Up Monday, June 23, 14
  • 14. Structure front Server Internal server send Request ... ... Too Much Code To Handle Monday, June 23, 14
  • 15. Service Definition • Front server can be flexible to connect • Support Restful API for internal connect • Same Router rule for client • Modules install / uninstall be easy • Light way feedback data Monday, June 23, 14
  • 16. Server Definenation • Front server can be flexible to connect • Support Restful API for internal connect • Same Router rule for client • Modules install / uninstall be easy • Light way feedback data Service as a module, feature as a apps https://github.com/clonn/module-loader Tips Monday, June 23, 14
  • 17. app3 app2 app1 app4 Routers as apps, auto route Monday, June 23, 14
  • 18. app3 app2 app1 app4 Every developers can handle by themselves Monday, June 23, 14
  • 19. Make connect easy, A tiny distribution server Monday, June 23, 14
  • 20. Face Response Issue ... Monday, June 23, 14
  • 21. Wait ...Wait ...Wait ... https://www.flickr.com/photos/tormodspictures/ Monday, June 23, 14
  • 22. 伺服器反應很慢 http://chinese.engadget.com/2014/06/21/facebook-android-update-africa/ Monday, June 23, 14
  • 23. Let’s refactoring code Monday, June 23, 14
  • 24. Monday, June 23, 14
  • 25. Response back as soon as posible Monday, June 23, 14
  • 26. Heavy processing or request, put late Monday, June 23, 14
  • 27. Response as short as posible https://www.flickr.com/photos/calliope/ Monday, June 23, 14
  • 28. what can NOT be late • real time date, have to be light (geo, data) • robust data, we could not avoid (but save in cached, redis and process them later) Monday, June 23, 14
  • 29. What can late • log data writing • data saving (not for real time response) • data caching Monday, June 23, 14
  • 30. Response First, Process Later Tips Monday, June 23, 14
  • 31. Too many callback event in waiting queue https://www.flickr.com/photos/peter_curb/14318113011/sizes/c/in/photostream/ Monday, June 23, 14
  • 32. WARNNING, It Cause High CPU Usage https://www.flickr.com/photos/peter_curb/14318113011/sizes/c/in/photostream/ Monday, June 23, 14
  • 33. We put process in Task Queue. http://learnboost.github.io/kue/ Monday, June 23, 14
  • 34. Save process, prarams in Task Queue Monday, June 23, 14
  • 35. Monday, June 23, 14
  • 36. Set callback event when things done Monday, June 23, 14
  • 37. Send request to 3rd party library / API / URL Monday, June 23, 14
  • 38. Feedback to Server or Storage trigger callback event to Server Monday, June 23, 14
  • 39. Monday, June 23, 14
  • 40. How feedback to clients, when task queue process task / jobs done, how could we notify clients? How about Client? Monday, June 23, 14
  • 41. Time meet http://socket.io/ or Socket Monday, June 23, 14
  • 42. Client and Server connect via a Tunnel Monday, June 23, 14
  • 43. With handshake Monday, June 23, 14
  • 44. Structure Clients Server Server push Monday, June 23, 14
  • 45. Structure Clients Server Server push From single way to double ways Monday, June 23, 14
  • 46. Structure Clients Server Server push From single way to double ways JSON Ads Habit Monday, June 23, 14
  • 47. Server push, that means • Ajax mode changed • Browser can do more things • User request is getting more • Server has to afford more currency • Server has opportunity feedback data Monday, June 23, 14
  • 48. Let’s integrate with Socket.io / Socket and Task Queue Monday, June 23, 14
  • 49. Feedback to Server or Storage Monday, June 23, 14
  • 50. Return data to User in a few minutes Monday, June 23, 14
  • 51. Return data to User in a few seconds Monday, June 23, 14
  • 52. Increase User Experience Not Make Them Wait Monday, June 23, 14
  • 53. Monday, June 23, 14
  • 54. Cache Layer Monday, June 23, 14
  • 55. Storage Layer Monday, June 23, 14
  • 56. Part of access Monday, June 23, 14
  • 57. Part of heavy access Monday, June 23, 14
  • 58. Not finished yet Monday, June 23, 14
  • 59. Monday, June 23, 14
  • 60. http://letsnode.com/example-of-what-node-is-really-good-at Monday, June 23, 14
  • 61. http://mortarnpistol.com/2011/12/16/big-rigs-over-the-road-racing/ Monday, June 23, 14
  • 62. Monday, June 23, 14
  • 63. Monday, June 23, 14
  • 64. Rules • Make events as light as posible • Divide things to tiny • Heavy process throw to another way • Monitor app.js after done • Figure out bottlenecks • Decrease users idle / waiting time as posible Monday, June 23, 14
  • 65. https://www.facebook.com/groups/node.js.tw/ https://www.facebook.com/NodeJS.tw https://github.com/nodejs-tw http://nodejs.tw/ http://2014.jsdc.tw/ Monday, June 23, 14
  • 66. https://github.com/nodejs-tw/nodejs-book-beginner-guide Monday, June 23, 14
  • 67. @clonncd Monday, June 23, 14