Autobahn stateless or stateful?


Hello, I am interested in creating (in a context of web application) a microservice oriented architecture. It seems to me that communicates via websocket (which by nature maintains the connection between the client and the server) and also implements “wamp.session”. So I wonder if there is a way to use Autobahn | Python with the crossbar router in stateless mode to run the same service several times and balance the load. Thank you !



Ok, so I think the easy part of the answer is documented here;

Essentially, when you register an endpoint, you can do it more than once and calls to that endpoint will be distributed (according to the chosen schedule) between registration instances. So for example if you write a service that implements an endpoint that returns “Hello World”, then run the service three times (i.e. as three processes), then call the endpoint from ‘another’ process, assuming you chose the ‘round robin’ scheduler, each of the three instances of your service will be hit once, and your client will receive three “Hello World” messages.

With regards to stateful vs stateless, take this with a pinch of salt as my formal computing education ended way before this sort of definition became ‘a thing’, but given the connection between the client and crossbar router maintains a persistent session (and authentication information), I would say that it is inherently stateful. When you make a request, how that request progresses is dependent on the result of previous requests, specifically whether they authenticated for example. However, connections between clients and endpoints are not persistent, nor do the results of previous calls to that endpoint affect future calls, so I would be inclined to think of them as stateless.

However (!) whether your microservice is itself stateless I think is kind of up to you, it should be possible to make your WAMP endpoint either stateful or stateless as you choose … information about the connection and caller (and previous requests) ‘can’ be passed to your endpoint, whether you choose to have your endpoint act on this information is sort of up to you.

(Authentication and Authorisation is done on the client-crossbar leg of the call, and not something the microservice needs to worry about on the crossbar-endpoint side, i.e. the endpoint doesn’t need to know who’s calling and whether they are allowed to call as this has already been implicitly authorised by Crossbar)

… I’m just thinking about caveats to the above … specifically, if you implement authentication and authorisation via an external WAMP client (custom option), then I’m wondering if then, technically, the connection between Crossbar and Autobahn would be classified as stateless … yeah, I knew going in the second half of this answer was going to be a problem … :scream:



As @oddjobz explains, can natively scale microservices, here are some more links: