-3

I have a service A, Service B, and Service C. A database is attached to service B. My requirement is to send data from service A every second. Service B processes the received data and store it in the database. Service C fetched processed data from the database ( by interacting with Service B ) every 5 seconds.

My question is, In the interaction between A to B, Would POST request be more efficient than PUT request considering performance constraints ( RAM and CPU usage ). Note that the request from A to B is using the same URI. Additionally, while fetching data from the database ( which is also using a single URI ) will the PUT method give me additional performance efficiency over the POST method?

Abhijith.M
  • 89
  • 1
  • 3
  • 11
  • 2
    PUT and POST are meant for different things. Generally speaking if you want to create a NEW record in your service, then you use a POST. However, if you have an existing record and you want to (UPDATE IT), meaning you need to retrieve it from the DB, Update, Save, then that is a PUT. You can still use POST but the affect on the RAM/CPU is the same(if you use PUT/POST on this action) I suggest you read https://www.rfc-editor.org/rfc/rfc2616#section-9.5 to get general information – JCompetence Oct 08 '21 at 07:29
  • 1
    PUT and POST are just headers since PUT it's pretty much not available in any web server, they are there just to "differentiate" the request, but won't make any difference in performance – Alberto Sinigaglia Oct 08 '21 at 07:30
  • Does this answer your question? [What is the difference between POST and PUT in HTTP?](https://stackoverflow.com/questions/630453/what-is-the-difference-between-post-and-put-in-http) – Gaurav Jeswani Oct 08 '21 at 07:41
  • As others have already explained, the meaning of PUT and POST is different. Efficiency is not a criterion you should use to choose between them (aside from the fact that there is no inherent efficiency difference). Also, for fetching data, you should use GET and not PUT or POST. – Jesper Oct 08 '21 at 08:10

1 Answers1

3

There are no performance benefits between POST, PUT, DELETE. It's more a question of what your backend will do. Create a new entity? You might want to use POST. Update it? Use PUT. A more detailed answer between the two can be found here.

Pilpo
  • 1,236
  • 1
  • 7
  • 18