Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

REST or GraphQL? A Performance Comparative Study

Gustavo Pinto
September 24, 2019
290

REST or GraphQL? A Performance Comparative Study

Gustavo Pinto

September 24, 2019
Tweet

More Decks by Gustavo Pinto

Transcript

  1. @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
  2. @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
  3. @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 “ ”
  4. { "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] }
  5. APP1 APP2 APP3 Rest Rest Rest RocketBox TechTeams MyFeed (Dropbox

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

    TechTeams MyFeed (Dropbox simplified) (Trello simplified) (Twitter simplified) @gustavopinto
  7. 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
  8. 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
  9. 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
  10. Size of the document No reduction Reduction in 100% of

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

    the cases Reduction in 50% of the cases @gustavopinto