Pro Yearly is on sale from $80 to $50! »

REST or GraphQL? A Performance Comparative Study

Be6953eb1929f548597c7ebf2be91a22?s=47 Gustavo Pinto
September 24, 2019
82

REST or GraphQL? A Performance Comparative Study

Be6953eb1929f548597c7ebf2be91a22?s=128

Gustavo Pinto

September 24, 2019
Tweet

Transcript

  1. REST or GraphQL? A Performance Comparative Study Marcos Nazário @gustavopinto

    Gustavo Pinto Matheus Seabra
  2. ? @gustavopinto

  3. HTTP @gustavopinto REST

  4. @gustavopinto

  5. @gustavopinto

  6. @gustavopinto

  7. @gustavopinto GET https://hacker-news.firebaseio.com/v0/post/8863

  8. @gustavopinto GET https://hacker-news.firebaseio.com/v0/post/8863/points

  9. @gustavopinto https://hacker-news.firebaseio.com/v0/post/8863/author/ GET https://hacker-news.firebaseio.com/v0/post/8863/author

  10. @gustavopinto https://hacker-news.firebaseio.com/v0/post/8863/when/ GET https://hacker-news.firebaseio.com/v0/post/8863/when

  11. @gustavopinto https://hacker-news.firebaseio.com/v0/post/8863/flag POST https://hacker-news.firebaseio.com/v0/post/8863/flag

  12. @gustavopinto https://hacker-news.firebaseio.com/v0/post/8863/author/hide POST https://hacker-news.firebaseio.com/v0/post/8863/hide

  13. @gustavopinto GET https://hacker-news.firebaseio.com/v0/post/8863/comments

  14. @gustavopinto GET https://hacker-news.firebaseio.com/v0/post/8863

  15. @gustavopinto { "by": "pg", "descendants": 54, "id": 126809, "kids": [

    126822, 126823, 126917, 126993, 126824, 126934, 127072, 127217, 126889, 126875, 127535 ], "score": 47, "time": 1204403652, "title": "Poll: What would happen if News.YC had explicit support for polls?", "type": "poll" "score" : 25, "text" : "<i>or</i> HN: the Next Iteration<p>I get the impression that with Arc being released a lot of people who never had time for HN before are suddenly dropping in more often. (PG: what are the numbers on this? I'm envisioning a spike.)<p>Not to say that isn't great, but I'm wary of Diggification.<p>80% of the stuff that makes the front page is still pretty awesome, but what's in place to keep the signal/noise ratio high? Does the HN model still work as the community scales? What's in store for (++ HN)?", "time" : 1203647620, "title" : "Ask HN: The Arc Effect", "type" : “story" "text" : "Yes, ban them; I'm tired of seeing Valleywag stories on News.YC.", "time" : 1207886576, "type" : "pollopt" "parts": [ 126810, 126811, 126812 ] } GET https://hacker-news.firebaseio.com/v0/post/8863
  16. @gustavopinto { "by": "pg", "descendants": 54, "id": 126809, "kids": [

    126822, 126823, 126917, 126993, 126824, 126934, 127072, 127217, 126889, 126875, 127535 ], "score": 47, "time": 1204403652, "title": "Poll: What would happen if News.YC had explicit support for polls?", "type": "poll" "score" : 25, "text" : "<i>or</i> HN: the Next Iteration<p>I get the impression that with Arc being released a lot of people who never had time for HN before are suddenly dropping in more often. (PG: what are the numbers on this? I'm envisioning a spike.)<p>Not to say that isn't great, but I'm wary of Diggification.<p>80% of the stuff that makes the front page is still pretty awesome, but what's in place to keep the signal/noise ratio high? Does the HN model still work as the community scales? What's in store for (++ HN)?", "time" : 1203647620, "title" : "Ask HN: The Arc Effect", "type" : “story" "text" : "Yes, ban them; I'm tired of seeing Valleywag stories on News.YC.", "time" : 1207886576, "type" : "pollopt" "parts": [ 126810, 126811, 126812 ] } GET https://hacker-news.firebaseio.com/v0/post/8863
  17. @gustavopinto GET https://hacker-news.firebaseio.com/v0/post/8863 GET https://hacker-news.firebaseio.com/v0/post/8864 GET https://hacker-news.firebaseio.com/v0/post/8865 GET https://hacker-news.firebaseio.com/v0/post/8866

  18. @gustavopinto

  19. @gustavopinto GraphQL Developed by Facebook Publicly released on 2015

  20. @gustavopinto GraphQL Developed by Facebook Publicly released on 2015 GraphQL

    allows clients to define the structure of the data required, and exactly the same structure of the data is returned from the server, therefore preventing excessively large amounts of data from being returned “ ”
  21. @gustavopinto type Query {
 topStories(limit: Int): [Story] }

  22. { "data": { "hn": { "topStories": [ { "title": "Monte

    Carlo methods Why it's a bad idea to go to the casino" }, { "title": "Public Domain Movies" }, { "title": "Agent 355" } ] } @gustavopinto type Query {
 topStories(limit: Int): [Story] }
  23. Research Questions RQ: Which architectural model is the most efficient

    in terms of performance? @gustavopinto
  24. APP1 APP2 APP3 RocketBox TechTeams MyFeed @gustavopinto

  25. APP1 APP2 APP3 RocketBox TechTeams MyFeed (Dropbox simplified) (Trello simplified)

    (Twitter simplified) @gustavopinto
  26. APP1 APP2 APP3 Rest Rest Rest RocketBox TechTeams MyFeed (Dropbox

    simplified) (Trello simplified) (Twitter simplified) @gustavopinto
  27. APP1 APP2 APP3 Rest GraphQL Rest GraphQL Rest GraphQL RocketBox

    TechTeams MyFeed (Dropbox simplified) (Trello simplified) (Twitter simplified) @gustavopinto
  28. APP1 APP2 APP3 Rest GraphQL Rest GraphQL Rest GraphQL RocketBox

    TechTeams MyFeed (Dropbox simplified) (Trello simplified) (Twitter simplified) 350 LoC 270 LoC 471 LoC 388 LoC 171 LoC 265 LoC @gustavopinto
  29. APP1 APP2 APP3 Rest GraphQL Rest GraphQL Rest GraphQL RocketBox

    TechTeams MyFeed (Dropbox simplified) (Trello simplified) (Twitter simplified) 350 LoC 270 LoC 471 LoC 388 LoC 171 LoC 265 LoC JavaScript @gustavopinto
  30. network overhead Rest GraphQL Client @gustavopinto

  31. GraphQL Client Rest @gustavopinto

  32. GraphQL Client Rest GraphQL Client @gustavopinto

  33. GraphQL Client Rest GraphQL 1 2 3 100 requests 1000

    requests 3000 requests { 15x Client 1, 10, 100 users 1, 500, 1000 users 1, 1000, 3000 users Intel Core i7, 2.20GHz, 8 cores, 16 GB memory, running Ubuntu Linux @gustavopinto
  34. Size of the document @gustavopinto

  35. Size of the document No reduction @gustavopinto

  36. Size of the document No reduction Reduction in 100% of

    the cases @gustavopinto
  37. Size of the document No reduction Reduction in 100% of

    the cases Reduction in 50% of the cases @gustavopinto
  38. Size of the document No reduction Reduction in 100% of

    the cases Reduction in 50% of the cases @gustavopinto
  39. Time per request (ms) @gustavopinto

  40. Time per request (ms) @gustavopinto

  41. Time per request (ms) @gustavopinto

  42. Time per request (ms) @gustavopinto

  43. Time per request (ms) @gustavopinto

  44. None