Issue
Hello guys I am new to web development and related technologies. I would like to know whether each get request is a read operation and post, put and delete are write operations?
Is it possible to combine several write requests and do it as a single write request? For example, if someone likes a post, instead of writing that directly to database, is it possible to hold the request somewhere temporarily before writing it together with other similar requests? and if you do like that, does it save costs?
Thanks
Solution
Your question is very broad and open-ended and probably not well suited to Stackoverflow. I encourage you to Google tutorials that explain how HTTP and REST work (e.g. link).
HTTP is a protocol that underpins the Web and, essentially involves (HTTP) clients (e.g. your browser) making (HTTP) requests to some (HTTP) server that provides a response.
Every HTTP request includes a 'verb' (GET
, POST
, PUT
, UPDATE
) and each has a reasonably well-defined intent. E.g. GET
is what we commonly think of a browsing the web. Your browser requests e.g. https://stackoverflow.com/questions/65832394
and the Stackoverflow server provides the HTML that renders as this page. Other verbs are used to send data to a server.
It is often (but not always) true that GET
s involve reading from and e.g. POST
s involve writing to some form of 'backend' (e.g. database).
HTTP is a stateless protocol. There's no intrinsic correlation between any requests and responses. If you make e.g. 2 POST
s (e.g. Here's this thing
, And here's another thing
) from the same machine to the same URL, the only way that the server would be able to correlate these is if you were to include some form of identifying data (usually in the form of a header), e.g. {"user":"prehistoricbeast", "message": "First thing"}
, {"user":"prehistoricbeast", "message": "Second thing"}
. And, then the server would have to manage some state, i.e. 2 messages from prehistoricbeast
for you.
Even if you manage state like this in one server, you will have problems if you wish to scale out and add other servers. If server #x received {"user":"prehistoricbeast", "message": "First thing"}
and server #y received {"user":"prehistoricbeast", "message": "Another thing"}
, you'd need to share state across these machines too...
It is common (as @civfan suggests) to cache data in a server and there are many other useful mechanisms including queuing (pub/sub) etc. etc. to help with efficiency (throughput, cost etc) but these are all highly-dependent on your use-case, the services you have available etc.
Answered By - DazWilkin