Why Idempotency is very critical in Backend Applications

  Рет қаралды 23,285

Hussein Nasser

Hussein Nasser

Күн бұрын

Пікірлер: 52
@gillfromamritsar
@gillfromamritsar 4 жыл бұрын
Awesome video again, lot of these concepts I came to know cuz of your videos.
@hrishabhg
@hrishabhg 3 жыл бұрын
Love you being a quick and simple solver.
@upadajanki8447
@upadajanki8447 4 жыл бұрын
Explained nicely. Here is what I can think about your question. The API, which is used for shortening the URL, should first look into the DB (or wherever its stored) for the given input (assuming it would be URL) . in case URL exists in the DB, API should return the short URL for the same. if DB does't contain then only API should generate the new short URL and return. Assuming older data in DB is cleaned up or archived periodically.
@jacquesduplessis6175
@jacquesduplessis6175 3 жыл бұрын
Good stuff. Your question: Validate url to be created against the db, if found=send that, else create new one (store in db) and send short url
@litcode702
@litcode702 7 ай бұрын
for url shortner idempotency I would hash the payload and will take it as an idempotency key. this should be done because for a particular user requesting for shortening a URL with some properties i.e. short url being private / public etc will uniquely identify a short url request
@TannerBarcelos
@TannerBarcelos 5 ай бұрын
We are facing this problem at work big time. We are trying to build a massively high available system and we need our apis / services to be idempotent but many sub systems we manage via APIs are inherently not idempotent so it’s a high challenge.
@Aleks-fp1kq
@Aleks-fp1kq 10 ай бұрын
But if you keep refreshing the page it would generate a new key so even if your POST indempotent, since the new key is generated, it would still create a new resource. What am I missing here?
@meghaagarwal6159
@meghaagarwal6159 Жыл бұрын
Just a suggestion- Its a knowledge video, it would be better if you clearly narrate the things instead of speaking in an unclear accent.
@hadeedtmgggg5837
@hadeedtmgggg5837 7 ай бұрын
In case of url shortener we will save real link in db and when user send a request again we check if the link already existed in db we will send the shorten link of that link else we generate a new link if I t doesn't exist
@marting1219
@marting1219 3 жыл бұрын
HTTP POSTs are defined as NOT idempotent. Please use PUT when you define an idempotent endpoint to write to db.
@ravitejavankam2977
@ravitejavankam2977 3 жыл бұрын
To deal with idempotent request you can maintain checkoutId in checkout page and in the order page you can pass that checkoutId and you can ensure if an order is placed or not with that checkoutId
@vivekacharya3110
@vivekacharya3110 3 жыл бұрын
I have a partial resource update so I made that API as PATCH. And the operation and implementation is idempotent. But in REST PATCH is not idempotent. What's your thought on this? Is going with PUT a better design or PATCH with idempotent?
@hnasr
@hnasr 3 жыл бұрын
Think about it semantically. If you issue that resource update multiple times what well happen? If it is safe, use PUT else continue using patch or POST
@chaitanyaujeniya8601
@chaitanyaujeniya8601 3 жыл бұрын
Thanks for all the content!! Super helpful👍👍
@smoothbeak
@smoothbeak 4 жыл бұрын
You have a really wonderful voice and way of speaking!
@adityasethi9794
@adityasethi9794 3 жыл бұрын
you can explain stuff in few minutes and that's an art. people make 30mins videos on this lol. just puts me off
@mridul1161
@mridul1161 4 жыл бұрын
when you give example related to real world problems like the transaction one....video become much more interesting...........try make more relations with practial implementation of those please!!
@hnasr
@hnasr 4 жыл бұрын
Quarantine Coder thank you 🙏I did give an example in this video right? The ordering system ? Were you looking for something else specific let me know so i do better next time 😊
@mridul1161
@mridul1161 4 жыл бұрын
@@hnasr yeah.. Gave one in this.. That.. Why I liked this one.. I mean to say your experience with solving real world problem .. That amplifys the video
@namandubey20
@namandubey20 2 жыл бұрын
Hi Hussein, shouldn't we use put request instead of post in these cases to get idempotency ? That's why put requests are made, right ?
@mohammedroshan5647
@mohammedroshan5647 2 жыл бұрын
Hi , Does anyone have any implementation suggestion to handle de-duplication at Kafka consumer side ? i.e to make idempotent consumer which will discard dupllicate messages from Kafka in the event of any broker or offset issues. One solution aware of is to store last read consumer offset number in a database. Store the offset number and msg values in single update call to ensure atomicity. Whenever consumer reads again, it check in the DB to ensure is not reading offset number less than already in the DB. Downside is if DB is huge , it will be perfomance impact. Another possible way is store topic name and last read offset number in a seperate table. Any other recommended practice ?
@fartzy
@fartzy 2 жыл бұрын
Another great video man!
@joeygarcia7826
@joeygarcia7826 3 жыл бұрын
I would hash the passed in url and store this hash and data in a database. The hash would be the primary key, so for every future call I can do a quick search and return what is already stored, otherwise run it through the url shortener and store it.
@sbylk99
@sbylk99 3 жыл бұрын
Great video, thank you
@NikhilTripathy
@NikhilTripathy 4 жыл бұрын
Hussein Nasser, you are a gem! May god bless you.
@hnasr
@hnasr 4 жыл бұрын
Nikhil Tripathy thanks Nikhil God bless ❤️ enjoy the content
@yodude2493
@yodude2493 2 жыл бұрын
Love you Hussein thank you very much for contributing a lot to community we see how hard it is how much time it takes and we appreciate that, keep going man!
@abhinavpandey2772
@abhinavpandey2772 3 жыл бұрын
URL Idempotent: Can we put URL Mapping in the Protobuf?
@Cdswjp
@Cdswjp 3 жыл бұрын
How about.... I have an idea.... how about..... a video that shows how to do retries
@aseel1024
@aseel1024 3 жыл бұрын
يعطيك العافية ممكن فيديوهات عن الفرونت اند والاخطاء الي يجب تجنبها مثل المذكورة في الفيديو وبلتحديد في اطر العمل مثل React js
@animatedzombie64
@animatedzombie64 3 жыл бұрын
i love that moment when Hussein laughs at some hole in the system.
@aaronrasing2710
@aaronrasing2710 3 жыл бұрын
Greate video Hussein! I really love how you explained it. I've always had a small understanding of this topic and with your video, I get it completely now.
@sumarouno
@sumarouno 4 жыл бұрын
I just know about this from this video
@hnasr
@hnasr 4 жыл бұрын
It is an important concept, learned about it while researching Kafka around a year ago. Thanks for watching 🙏
@zaheerkhan8097
@zaheerkhan8097 4 жыл бұрын
Very well explained !!
@satyamsinha5429
@satyamsinha5429 3 жыл бұрын
Nice ! Followed you .
@Raaviolis
@Raaviolis 4 жыл бұрын
Isn’t idempotency like atomic isolation “A” “I” transaction from ACID concurrency rules ?
@hnasr
@hnasr 4 жыл бұрын
Ravi Hindocha Hey Ravi, there are some similarities but also very big difference between the two properties. Check out my ACID video for details 😊
@Raaviolis
@Raaviolis 4 жыл бұрын
Hussein Nasser Appreciate , I have knowledge about acid(not in hippy way) just trying to mash up two worlds, and trying to find common principles, between http and sql world they are kind of doing same crud operations let’s say you order pizza a you will put the order and wait for transaction to complete at the check out window and you if update the order again, so basically aa = a , if that is translated in acid principles in a finite state machine once you insert the record to buy, isolate the transaction meaning give a uuid to it and make sure it’s atomic all or nothing meaning you ordered once exactly once, no updates or cancelation yet if they are it will be a separate finite transaction , same state is consistently preserved just once on same uuid transaction which is put or insert, so key part is isolation of the transaction in an atomic way and you can always roll back in case of failure, just thinking out loud let me know if you need clarification.
@footballhero9717
@footballhero9717 4 жыл бұрын
استاذ حسين كنت عاوز اعرف منين انتا عارف كل هذي الاشياء انا اول مرة اعرفها لما دخلت على قناتك لو تدلني على مكان اقدر اعرفها زيك اكون شاكرلك بقية حياتي
@hnasr
@hnasr 4 жыл бұрын
Football Hero اهلا عزيزي، القراءه المستمره، استماع للبودكاست ، مشاهده فيديوهات. رما زلت اعتبر نفسي لا اعرف اي شي. وعاء العلم لا يمتلى بما فيه. بالتوفيق شاهد هذا الفيديو اتكلم بالتفصيل My Preferred Method of Learning Backend Engineering Technologies kzbin.info/www/bejne/an_WiKGKlJJ5pac
@footballhero9717
@footballhero9717 4 жыл бұрын
@@hnasr اشكرك استاذ ناصر على كرمك و مساعدتك لنا و انا اوعدك في يوم حردلك هذا الجميل 💙💙💙💙
@neeravarora530
@neeravarora530 4 жыл бұрын
All your videos are awesome.
@shivangchaturvedi237
@shivangchaturvedi237 3 жыл бұрын
Crisp! 😀
@alfredskaria
@alfredskaria 4 жыл бұрын
Great video Hussein. However I have one doubt. In the video you explained that for making the request as idempotent, we can create a client id for a request. So , suppose if two POST requests are coming from two different devices ( not concurrently) , then there can be a case where client id becomes different. So it can end up in creating two records in the DB. But , my requirement is to update the record created by the 1st POST request. In such scenario, how do we handle idempotency? Or can we use client id approach?
@amila325
@amila325 4 жыл бұрын
You use PUT requests to update and use POST for inserts. Therefore if you send a post request from two different clients it should enter two new records. But lets say you can’t do that. In that case you will have to create some sort of a hash key from fields which are not gonna get updated and unique to that record.
@alfredskaria
@alfredskaria 4 жыл бұрын
@@amila325 Thanks Ami, I was also thinking about a similar kind of solution.
@yadrielgonzalez1
@yadrielgonzalez1 4 жыл бұрын
Great video!
@shafeeqr2
@shafeeqr2 4 жыл бұрын
Your question is very interesting. Typically we want to allow multiple shortened URLs for the same input URL (for different reasons) but at the same time we want to avoid loss of idempotency. I would take a hash of the URL and store it in the database. I would also store the Datetime of said request in YYYYmmDD HH format. I would create a unique index in this table as the composite of the hash and datetime. The result is we will not allow the same URL to create multiple shortened URLs in the same hour. If user requests the same URL in the same hour, our endpoint can return the pre-existing value from the database.
@rampandey191
@rampandey191 4 жыл бұрын
Hey can you explain the reason to create different shortened URLs for same URL? Because I think it should not be allowed
@lonerider543
@lonerider543 3 жыл бұрын
@@rampandey191 Bit late to the party, but I'd assume for analytics (as an example) you'd want to allow multiple. Let's say I create a shortened URL that leads to a popular website and someone else does the same. We only want to see however how much traffic that shortened URL is getting from wherever we have shared the URL to. If both people get the same shortened URL, then the analytics would get mixed up together. By creating 2 shortened URLs for the same URL this wouldn't happen and each of the 2 users would have their own URL that they can share and keep track of how much traffic they are getting from it.
@rampandey191
@rampandey191 3 жыл бұрын
@@lonerider543 makes sense thanks
The Pros and Cons of Encrypted Client Hello
32:30
Hussein Nasser
Рет қаралды 6 М.
What is API Idempotency and Why Is It Important?
12:13
Be A Better Dev
Рет қаралды 39 М.
Help Me Celebrate! 😍🙏
00:35
Alan Chikin Chow
Рет қаралды 56 МЛН
Nastya and balloon challenge
00:23
Nastya
Рет қаралды 70 МЛН
когда не обедаешь в школе // EVA mash
00:57
EVA mash
Рет қаралды 3,7 МЛН
Installing an ADDS domain controller
16:48
David Dalton
Рет қаралды 7
Microservices Explained and their Pros & Cons
16:40
Hussein Nasser
Рет қаралды 56 М.
When should you shard your database?
21:20
Hussein Nasser
Рет қаралды 78 М.
40 Years Of Software Engineering Experience In 19 Minutes
19:10
Continuous Delivery
Рет қаралды 83 М.
MongoDB Internal Architecture
43:25
Hussein Nasser
Рет қаралды 87 М.
Idempotency - What it is and How to Implement it
8:05
Alex Hyett
Рет қаралды 16 М.
Publish-Subscribe Architecture (Explained by Example)
30:03
Hussein Nasser
Рет қаралды 118 М.
Help Me Celebrate! 😍🙏
00:35
Alan Chikin Chow
Рет қаралды 56 МЛН