Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there any time difference between different responded requests,

I am curious about one thing.

For example let’s say, I am going to update my email on a website. My userId is: 1.

My request body for a successful request is:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

currentEmail: example1@gmail.com,
newEmail: example2@gmail.com,
userId: 1

I will get a successful response for above. But the request below will be failed because there isn’t any user with the userId of 2:

currentEmail: example1@gmail.com,
newEmail: example2@gmail.com,
userId: 2

Will there be any reasonable time difference between these two? Because second request won’t trigger any database writing.

And also let’s say I will try to find a user with a userId.

GET api/findUser/{userId}

If there isn’t any user with the userId above, will there be any time difference between successful and failed requests?

>Solution :

If you’re "curious" – go ahead and measure it, the real results will depend on the API implementation, DB implementation, caching on DB and ORM levels, etc.

For example if in 1st case the API just calls SQL Update statement – the execution time should be similar, however if the API builds a "user" DTO first – the attempt to amend non-existing user will be faster.

In the latter case my expectation is that attempt to get info for the user which doesn’t exist will be faster, however it also "depends".

So you need to inspect the associated code execution footprint, query plans and maybe even load test the database separate from the API.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading