Grokking Spring Boot
Vote

0% completed

​

Pagination and Sorting

Asked for every seat of event 7 at once, GET /events/7/seats returned 600 seats in 16,699 bytes of JSON. Asked for one row of 30 seats, it returned 910 bytes. The app shows one row at a time, so the first answer sent about 18 times more data than the screen could use.

The cost grows with the venue. Suppose a stadium had 50,000 seats. At the same 28 bytes or so per seat, one request would return about 1.4 million bytes, and the service would convert all 50,000 seats to JSON for every such request.

The answer is to return the list in slices that the client asks for by number

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content