Knock Knock Hey !!!! server is there any update ? No.
Knock Knock Hey !!! server is there any update ? No.
and this goes on….
Cron behaves exactly like this when it tries to get data from any 3rd party server to be updated. Which wastes a lot of resouces to both server and client side.
Possible cases :
- Single client on a server.
- Multiple clients on a server.
- Server callback updates to its client’s address.
Now think about case 1, client will keep ping server for data again and again and server will return null until it has data. Result — waste of time for the client and the server both.
Case 2 : Huge load on server and all will get null :) until server dies or data is found. It’s like all students asking for his/her result from a single person.
Case 3 : Just think as provider stores subscriber’s id and notify them as there data is found. Cool !!!.
Webhook is similar to case 3. Here server returns callback when conditions are satisfied, without knocking each others and both are free to do their work or rest.
Client has to provide these parameters (depends upon server):
1 : Webhook API end point.
2 : HTTP method.
3 : Secret key.
Here client has no data in its database so, it checked in third party server and server also doesn’t have data. So, it has created a subscription to update when it gets data and the client has created an empty data.
Here client didn’t request third party server as it knows server also doesn’t have it and it will call me once it gets.
Here comes Webhook, as soon as server gets the data it checks all subscribers and updates them. If client is down then it will retry.
Also, as client API endpoint is public, there is chance of getting incorrect data, so secret key is passed from client-server-client to make sure data is coming from genuine location. Now client can modify data and notify its user.
Many services like payment gateways, Git, Slack use webhook to keep their clients updated. For example one product price gets updated and is hosted on multiple platforms. In that case, will you go on each platform and update or write a webhook for it !!!!!.
No more knock knock, keep calm you will be updated.