Gökhan Uçar
Gökhan Uçar

Reputation: 226

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:

currentEmail: [email protected],
newEmail: [email protected],
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: [email protected],
newEmail: [email protected],
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?

Upvotes: 0

Views: 38

Answers (1)

Dmitri T
Dmitri T

Reputation: 168082

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.

Upvotes: 1

Related Questions