Question

So let's say in a Service Oriented Architecture, you have 3 layers:

  1. The Web/External Layer - what the user sees
  2. Application Logic - generates layer 3. handles users, sessions, forms & etc...
  3. Internal API - your data, and how to access data

Now 1 and 2 live in the same network so latency is our least thought of problem. Essentially, layer 2 consumes data from layer 1 using REST. I was thinking of alternatives to how data can be consumed.

What are the PROS and CONS of making layer 1 and 2 communicate with Websockets instead of REST?

Assuming, you have multiple servers and layer 2 applications.

This question is purely out of curiosity.

Was it helpful?

Solution

There is an old discussion on RESTfull HTTP vs websockets. I like to think of them as being different. In general, websockets will give you finer control. With that comes perhaps more efficiency --imagine if you, say, define your own protocol. The downside is that you will have a less standard approach. REST is less flexible but more standard and more loosely coupled.

Stefan Tilkov summarized it pretty well in his blog post. There is also a related discussion here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top