Duration 6:5

Top 7 Ways to 10x Your API Performance

253 990 watched
0
11 K
Published 2023/07/27

Get a Free System Design PDF with 158 pages by subscribing to our weekly newsletter: https://bytebytego.ck.page/subscribe Animation tools: Adobe Illustrator and After Effects. Checkout our bestselling System Design Interview books: Volume 1: https://amzn.to/3Ou7gkd Volume 2: https://amzn.to/3HqGozy The digital version of System Design Interview books: https://bit.ly/3mlDSk9 ABOUT US: Covering topics and trends in large-scale system design, from the authors of the best-selling System Design Interview series.

Category

Show more

Comments - 156
  • @
    @wissemaljazairiقبل 9 أشهر 1. Caching
    2. Connection Pool
    3. Avoid N+1 Query pattern
    4. Pagination
    5. JSON Serialization
    6. Compression
    7. Asynchronous logging
    .
    ...وسعت
    74
  • @
    @bananesalee7086قبل 9 أشهر for some reasons, listening to you is calming 17
  • @
    @narasimhareddy8323قبل 9 أشهر One quick question.
    Who does the video animation work for you? Kudos to the designer whoever he/she is.
    24
  • @
    @gregoirehebertقبل 9 أشهر 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 id="hidden2" class="buttons"> 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
    ....وسعت 11
  • @
    @asadbekfayzullaevقبل 9 أشهر Thank you! I love watching ByteByteGo system design videos! 5
  • @
    @kns6132قبل 9 أشهر Superbly explained and very valid tips ❤ 12
  • @
    @guhkunpatata3150قبل 8 أشهر the animation + explanation is GREAT! thanks for sharing!
  • @
    @harshdevsingh6506قبل 8 أشهر 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 id="hidden3" class="buttons"> 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.
    ....وسعت 5
  • @
    @Ajdin87قبل 9 أشهر 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 id="hidden4" class="buttons"> in memory, and oh boy do they love to make you pay for everything.
    Great video btw.
    ....وسعت 19
  • @
    @MrSongswordقبل 9 أشهر The 7 methods:
    1. Caching
    2. Connection pool
    3. Avoidn5" class="buttons"> N+1 Query Problem
    4. Pagination
    5. JSON Serializers
    6. Payload Compression
    7. Asynchronous logging
    .
    ...وسعت 46
  • @
    @anthonysallsقبل 9 أشهر 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
    .
    ...وسعت
    4
  • @
    @makhaerقبل 9 أشهر @ByteByteGo could you tell which tool you use to draw these animated diagrams ? 2
  • @
    @nmmm2000قبل 9 أشهر 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, id="hidden7" class="buttons"> speedup is considerable - this technique often used in SMS industry.
    - Optimize SQL queries :)
    - Optimize SQL queries :) :)
    - Optimize SQL queries :) :) :)
    - Database replication
    ....وسعت 36
  • @
    @MichaelKubler-kublermdkقبل 9 أشهر 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 id="hidden8" class="buttons"> thumbnail generation or OCR processing of files, complex Multi-document (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.
    ....وسعت 3
  • @
    @thanhnx-vnitقبل 9 أشهر @ByteByteGo
    Video is great. Thank you so much!
    Btw, could you tell me the software to create presentation slides like in the video?
    2
  • @
    @leomyskyقبل 9 أشهر Wonderful
    Thank you for the video
  • @
    @ravipvkiranpvقبل 9 أشهر Add Streaming to the list.. Great video..
  • @
    @jacob_90sقبل 7 أشهر 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 id="hidden9" class="buttons"> 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. ....وسعت 6
  • @
    @arfinexe539قبل 9 أشهر Great video, but that car transition caught me off guard 3
  • @
    @khari_baatقبل 9 أشهر Which efficient JSON serializer are we talking about? Can you please suggest some? 1
  • @
    @pauljohnsonbringbackdislik1469قبل 7 أشهر Since browsers limit active parallel downloads, there are some cases when batching requests may shave 2-5s from the overall page load (e.g. on pages that id="hidden10" class="buttons"> tend to load multiple data to compose a report or a summary).
    I wish @ByteByteGo could make a follow-up video with "Top 7 ways to optimize performance suggested by community" :)
    ....وسعت
  • @
    @leetcode7857قبل 9 أشهر Other techniques:
    1. Tuning the database connection pool size based on the application behaviour. (Large number doesn't always mean more performance) id="hidden11" class="buttons">
    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.
    ....وسعت 260
  • @
    @dmitrypichugin7449قبل 9 أشهر Bulk REST endpoints (controller architype)
    REST -> GraphQL
    2
  • @
    @nagsworldقبل 8 أشهر your video's looks greate, mainly presntation along with content. What tool you are using for animations?
  • @
    @orisueXtriumvirقبل 7 أشهر What techniques can we use for an endpoint that handles file download requests where the data content can change for each request?
  • @
    @TariqSajidقبل 9 أشهر 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 6
  • @
    @LNSFLIVEقبل 5 أشهر what you using to make your visualizations? animations are great
  • @
    @danregep4646قبل 9 أشهر what about avoiding memcopy and serialization by using an optimized data-serialization format? (TRIFT PBufers etc)
  • @
    @SalvadorFariaقبل 9 أشهر Other optimization techniques: Partial Responses and Field Masks - Request specific data fields, reduces processing load, and improves efficiency in API interactions. 13
  • @
    @efnobregaقبل 2 أشهر HiThere! Please, let me know what tool do you use to create the videos graphics / animations. Ths!
  • @
    @CarlosGonzalez-rg6htقبل 9 أشهر I think data partitioningnin line to the querying to be performed could be a usefull method to improve performance.
  • @
    @hemantpanchal8087قبل 9 أشهر Can someone please help me in below scenario.
    Eg. My program has more than 1.5 lakh employees records in database and this data won't get id="hidden14" class="buttons"> change so frequently.
    So is it good idea to publish json of individual employee on azure blob/s3 and than from Api we can read from Here and display in front-end.
    I would like to know whether it will impact read performance for 1.5 lakh json on azure blob.
    ....وسعت
  • @
    @Ashirgaziyevقبل 4 أشهر Hey guys, I know this might be a silly question; however, what would be the great learning material for a newbie backend developer?
    I am considering id="hidden15" class="buttons"> to switch from mobile development to backend development asap. Thanks a lot!
    ....وسعت
  • @
    @iSerjioLقبل 4 أشهر I would point out the 3rd technique "Avoid N+1 Problem" into a separate section - Database Query Optimisation, including proper indexes, query id="hidden16" class="buttons"> optimisation, usage of memory-optimised tables, cluster configuration (DB setup, e.g. using SSD, temp db size, transaction isolation level) etc. ....وسعت
  • @
    @JIANGNIANHANGقبل 8 أشهر I have 2 doubt/question:
    5. JSON Serialization
    which json library should been used?
    Does json libraries has really large difference id="hidden17" class="buttons"> in performance?
    7. Asynchronous logging
    Dose logging method can improve API performance?
    ....وسعت 1
  • @
    @infomaniac50قبل 9 أشهر When doing compression on API responses, make sure you're not exposing yourself to a CRIME attack. CVE-2012-4929 65
  • @
    @Mo-bs7ctقبل 9 أشهر You may need indexing to speed up queries 3
  • @
    @BhaveshAgarwalقبل 8 أشهر ByteByteGo - please share the tools and softwares you use to create these wonderful videos. It will be extremely helpful to learn them and use it for work and share knowledge in general. Thanks in advance!
  • @
    @Achrafsoukقبل 9 أشهر CDNs like CloudFront also can help with connection pooling. 2
  • @
    @vighnesh153قبل 9 أشهر You could also consider replacing JSON with protobufs. They are super optimized for data transfer between systems. 24
  • @
    @TomDoesTechقبل 9 أشهر Anyone know how he makes these animations? 1
  • @
    @diegofelipe91قبل 6 أشهر In MongoDB it's not good to use skip and limit approach to pagination, specially when you're paginating over a huge number of documents, it's more suitable to have a find and limit approach instead.
  • @
    @andrewwhitehouse1878قبل 9 أشهر This is gold. Your whole channel is gold and the production values are amazing ❤ 1
  • @
    @user-xe9on9yr7cقبل 8 أشهر What about binary optimization and grpc?
  • @
    @user-ns2fz1tl9sقبل 9 أشهر Pagination could be very difficult and confusion on some databases. For example Postgres have to read all previous pages, to read 101 page. So on really big datasets just limit\offset leads only to problems.
  • @
    @sarakhushi23قبل 6 أشهر 1- Caching , Store result comoutation so that can be used later in Redis..
    2- Connection Pool-
    3- Avoid N+1 Query problem
    4- Pagination id="hidden21" class="buttons">
    5- Lightweight JSON Serialization..
    6- Compression..
    7- Asynchronous logging..
    ....وسعت
  • @
    @aravind.aقبل 9 أشهر Hi Team, can you please explain serialization in detail?
    Does it mean - instead of sending the json / xml it is better to send as string ?
  • @
    @andrasczinegeقبل 9 أشهر Thanks for the awesome video. I use Azure Functions that often read and write from/to a database, and I am just wondering what if I create a connection id="hidden22" class="buttons"> pool in sqlalchemy and bind it to an engine on the startup of a python azure function. Every time a function is called, azure function starts a new threard to handle the request, and those theads could use that connection pool, which is said to be threadsafe. This way I could reuse connections even though I am running serverless python azure functions. Is it not possible? @ByteByteGo ....وسعت
  • @
    @rajatmathurقبل 9 أشهر Can you share some fast JSON serialization libraries for Java?
  • @
    @_sk_videosقبل 8 أشهر Any suggestions on how to improve an API that returns a large amount of data, 10-200MB?
  • @
    @olhoTronقبل 2 أشهر Its worth stressing: ALWAYS measure, before, during and after an optimization, and check if the performance really improved and the results remained the id="hidden23" class="buttons"> same. Gut feelings don't work when optimizing software
    Also think of the system as a whole, sometimes what shows up at the top on the profiler is the symptom and not the cause of the problem
    ....وسعت 1
  • @
    @myrondaiقبل 7 أشهر Use uncrowded resources for crowded resources: computing for memory/bandwidth (compression), memory for computing (Cache);
    reuse objects; id="hidden24" class="buttons"> />Avoid unnecessary calculations;
    Question: Why do people want to do pagination? "User interface has limited place to display data, so we only fetch what we needed. " is one explanation. Anything else?
    ....وسعت
  • @
    @ColossalMcBuzzقبل 6 أشهر Tip #8: Ensure you're using the right data structures and/or algorithms for the endpoints.
  • @
    @114dev8قبل 8 أشهر Hey guys, I was wondering if anyone can propose some good database architectures that can help to improve.
  • @
    @TheOnlyEpsilonAlphaقبل 4 أشهر Other Techniques:
    1. Key Pool for Oauth Operations:
    - When you want to reduce the waste of individual overhead, that comes from the whole id="hidden25" class="buttons"> process of ongoing re-rolling API Keys, make a dedicated component for that to have a pool available of valid API Keys or Tokens, so the components which need to work with the API don't have to go through the whole API Key managing process and just do their stuff.
    - By letting a dedicated component manage those pool for you, keep an eye that are always enough valid entries available. Based on the need the component can request a bigger amount of keys
    - The Life-cycle of that keys and be easily managed by storing them in a redis database with EXPIRE set, so it will get deleted when it's expired also in the according API.
    ....وسعت
  • @
    @Rscnry99قبل 9 أشهر @bytebytego what app do you use for your animations?
  • @
    @phoenicianathletix2866قبل 9 أشهر Can Payload Compression be used while using Web sockets? 1
  • @
    @robl39قبل 9 أشهر Fun fact: doing pagination killed performance at the database level for my product. We were using offset fetch in sql server and we quickly going out that id="hidden26" class="buttons"> once a given table reaches a certain size it slows way down. To solve this we introduced a “bookmark” methodology that doesn’t need to perform a table scan ....وسعت 1
  • @
    @zakrawقبل 9 أشهر Surprised you didn't mention Eager vs Lazy Loading, Database indexing, Breaking excessive SQL queries with multi-level subqueries into smaller ones. 3
  • @
    @santosh_bhatقبل 3 أشهر Someone please tell me how to make such animations?
  • @
    @jwbonnettقبل 9 أشهر JSON is the old defacto, Protobuff is the new one.
  • @
    @LCTeslaقبل 7 أشهر kinda kills the idea for me. that's when logs are most important
  • @
    @globalcitizen123-hl3dvقبل 9 أشهر wait I had no idea you wrote the system design books hahaha damn, I'm stupid. I'm a technical program manager that works with Platform/Infra teams id="hidden28" class="buttons"> (but don't really have a background in either lol) so I used these books as reference. very useful. ....وسعت
  • @
    @nixonrodقبل 9 أشهر master slave | partitioning | sharding techniques for improving database performance.
  • @
    @jon9103قبل 3 أشهر Paging is often poorly implemented in practice because the ordering of items does not stay consistent between page loads leading to some items being missed and others duplicated and a jarring UX.
  • @
    @rollinOnCodeقبل 9 أشهر the n+1 query can be huge and tends to happen when you got scope creep.
  • @
    @Nephtys1قبل 9 أشهر This is missing the number 0 of optimization: deleting your api / get rid of it entirely. Nothing is faster or cheaper than no code.
    Contrary to id="hidden30" class="buttons"> popular belief, this is most of the times the first and best optimization.
    Last year I optimized a specific 'Microservice' away by moving its 'logic' (nearly nothing really useful) to the client. Decreased latency of the whole feature by 80%, and decreased total LOC.
    Always try to localize operations or data if your goal is speed and efficiency.
    ....وسعت
  • @
    @amanccaقبل 9 أشهر Image compression is one of my favorite one. My API can reduce image from 5MB to 10kb 3
  • @
    @VadimFilinقبل 9 أشهر do not use offset! use cursor pattern instead 4