Top 7 Ways to 10x Your API Performance

preview_player
Показать описание

Animation tools: Adobe Illustrator and After Effects.

Checkout our bestselling System Design Interview books:

ABOUT US:
Covering topics and trends in large-scale system design, from the authors of the best-selling System Design Interview series.
Рекомендации по теме
Комментарии
Автор

1. 1:00 Caching
2. 1:45 Connection Pool
3. 2:45 Avoid N+1 Query pattern
4. 3:35 Pagination
5. 3:58 JSON Serialization
6. 4:20 Compression
7. 4:50 Asynchronous logging

wissemaljazairi
Автор

for some reasons, listening to you is calming

bananesalee
Автор

Other techniques:
1. Tuning the database connection pool size based on the application behaviour. (Large number doesn't always mean more performance)
2. Optimizing the SQL query. (Ensuring your most frequent queries end up using index scan instead of full table scan)
3. Not hopping between multiple microservices for a single user request. (While a single user request can hit multiple services but those services should not in turn hit another set of services and so on).
4. Authorization data should be always cached.
5. As much as possible, do the most computation on the database layer. There's a huge difference between doing the computation at application layer vs doing it at database layer.

leetcode
Автор

One quick question...

Who does the video animation work for you? Kudos to the designer whoever he/she is.

narasimhareddy
Автор

Around the N+1 problem, I think it's worth mensionning that using HTTP Cache on the comments would reduce the amount of processing. No need to claim them all at once. The pagination approach is still valid ! A simple IRI toward the collection of comments is also valid.
But you still need to request them at some point, even if this is to the cache reverse proxy.
To avoid waiting your frontend to parse the payload then query the comments, the use of 103 EarlyHint can eliminate that waiting time.

Using HTTP/2 as it is using binary frames, multiplexing and solves HOL blocking.
Using HTTP/3 as it speed up establishing the connecion API.

Formats like protobuff also reduces the size of the payload.

To circumvent pipelining problems using HTTP/1.1, sometimes batch HTTP request can be a solution (prefer standard specification) But please stay stateless as much as possible.

Of course the infamous domain sharding 🤐

gregoirehebert
Автор

2 cents from me too:

- Use HTTP keep alive or HTTP2 - if you do separate HTTP call for each API call, speed will be slow. if you do HTTP keep alive, speedup is considerable - this technique often used in SMS industry.
- Optimize SQL queries :)
- Optimize SQL queries :) :)
- Optimize SQL queries :) :) :)
- Database replication

nmmm
Автор

Thank you! I love watching ByteByteGo system design videos!

justmasdd
Автор

I think it is worth mentioning that if you decide to use caching, Redis, and you are using, for example AWS, it will be additional cost. Caching is done in memory, and oh boy do they love to make you pay for everything.

Great video btw.

Ajdin
Автор

1. Tunning database tables like purging old data which is not needed can minimize the performance of select queries on tables.
2.Putting the index on the column of the table also helps the same.
3.Adding load balance also helps to improve the performance.
4.payload compression also can be helpful to fetch large size data like image/videos.

harshdevsingh
Автор

The 7 methods:
1. Caching
2. Connection pool
3. Avoid N+1 Query Problem
4. Pagination
5. JSON Serializers
6. Payload Compression
7. Asynchronous logging

MrSongsword
Автор

Superbly explained and very valid tips ❤

kns
Автор

An architecture I work with involves a secondary copy mirror, and I once “crashed” the mirror by supplying too many writes to primary that were handled effortlessly at source but the synchronous writes to the secondary DB backed up as a result of its lower tier hardware and all applications that ran on the secondary (non time critical systems like operational reporting that can usually wait the .8 seconds to run while secondary catches up to the point the job originated from primary) stalled for hours and refused all new jobs and queued all writes in that period.


Switching to asynchronous log writing dramatically improved the performance and the secondary system could handle the load fed from primary again, but there was half a day of 40, 000 users who were not happy that their reports when from taking half a minute to run to half a day. Additionally HA and data loss was risked as the secondary system was the same-data center backup of primary (there was another primary off site with similar hardware that kept pace but would have taken longer to fail over to).

The lesson is, if production is reliant on secondary systems it communicates with, and you’re going to be running production hot for hours, you must have secondary systems attached to your test suite! We’d 4 dozen attached but missed the mirror that was instrumental for reporting 😅

anthonysalls
Автор

Other optimization techniques: Partial Responses and Field Masks - Request specific data fields, reduces processing load, and improves efficiency in API interactions.

SalvadorFaria
Автор

Hidden thing about pagnation is be very careful of the total count query that might be taking too much time if you do on every pagination request and you have large dataset

TariqSajid
Автор

Great video, but that car transition caught me off guard 😂

arfinexe
Автор

One issue to look out for with pagination when using TOP/MAX and OFFSET are changes that occur between page request and how they affect the order of the data. I've worked with several API's where a record on page 1 would be changed after I had already accessed that page, and it changes the order of all the results, so when I would grab the next page, the results would be shifted over and I would miss some of them.

jacob_s
Автор

the animation + explanation is GREAT! thanks for sharing!

guhkunpatata
Автор

Something we recently did was use Amazon SQS to push after save and after update tasks to a background processing server.
This allows things like thumbnail generation or OCR processing of files, complex Multi-document updating (updating one entry will cause fields on multiple other entries to be updated in different ways) and things like updating the Lucene search system, or generating notifications or user activities event stream, all can be done on the backend server moments later instead of during the API call.

Of course we are using PHP not something like NodeJS where processing after an API response is much easier.

MichaelKubler-kublermdk
Автор

You could also consider replacing JSON with protobufs. They are super optimized for data transfer between systems.

vighnesh
Автор

This is gold. Your whole channel is gold and the production values are amazing ❤

andrewwhitehouse