Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
C0D4669026yI've never considered sockets for that kind of thing.
I find sockets a pain in the ass on the best of days and that's for small scale projects, let alone going all in for an e-commerce system and APIs. -
@norman70688 what cost would that be?
OP's question is a good one. I was also wondering about the same thing -
Pointless drain on server resources to keep a managed connection open if you don't require real-time two-way data flow.
Standard HTTP makes more sense for one-way transactional communication. -
TobiSGD2816yWhy not both. In our new project we use an SPA that gets its data from a standard REST-API, but also connects to a websocket. The websocket-connection is for telling the client that a specific resource has been updated, so that the SPA can decide if it has to update the cached data or not.
This way we get a rid of polling and we minimize data-transfers. -
@netikras since socket connections are persistent there is a maximum number a server can handle at once.
On some servers they also consume from the HTTP connection pool . -
@kwilliams limited to what, 65k? It seems quite unrealistic to reach this limit for the mentioned purpose, doesn't it?
Ulimit limitations can be easily lifted - this step must always be planned as a part of infra architecture anyway
How are websockets different from a longpoll [considering socket exhausion]?
Afaik push notiffs use this very model - longpoll. Meaning server has thousands of sockets opened by a client, which are doing nothin but sitting in some collection and waiting to be used. The only overhead I might see is keepalive bombing, but even there I don't see much of a waste.
MQs, which is a pure serverside-ware, also uses longpoll for subscriptions/queue drains. Haven't seen any problems there as well. Did I miss smth?
Cloud doesn't even charge for this -nofiles resource last I've checked
Please correct me if I'm wrong -
@kwilliams sh!t. I should learn to read better 😁
yupp, you're right. Idk why nor how, but I thought that OP is asking about comms between microservices through their APIs
I need a good night sleep :( -
@TobiSGD Websocket or webhook? And just curious but why not use web hooks instead so when there’s and update you just send the notification to the client that’s waiting rather than having an open connection all the time? Unless updates are super frequent
-
TobiSGD2816y@badcopnodonuts Websockets. The clients accessing the REST-API can in our case be a web app, a mobile app or, in future, backends of other modules of the project. Webhooks aren't of much use with mobile apps or web apps.
Related Rants
Does anyone know why websockets aren't used far and wide for APIs? I mean not like chat applications, but the typical webapp, say an online shop. For me it seems kinda wasteful to fire separate requests with tiny payloads all the time. I currently use moleculer and socketio for a quite big project with multiple websites and backend containers, and so far, i haven't found a disadvantage.
So what have i missed?
question
rest
api
websockets