Does AWS Elastic Cache support Pub/Sub on Redis Cluster? - node.js

Looking the documentation of AWS Elastic Cache I can see they support Redis Cluster and talk about key/value data and Redis operations in general.
However is not clear for me if this will support replication of Redis' pub/sub along the different servers.
We are building a chat server on node-xmpp. We will have many application servers for handling chat connections and we are relying on Redis pub/sub for handling the communication between chat threads. We require that regardless the actual Redis instance each chat server is communicating to, they can share the same pub/sub channel.
At AWS Elastic cache white paper (page 7) they indicate to use Redis if you want pub/sub. I understand from this that AWS Elastic Cache will actual support pub/sub scalability but I'm not convinced yet.

I have tried it and yes, AWS manages pub/sub channels among Redis instances within a cluster. We have deployed now three chat platforms using node-xmpp and redis-cluster on AWS Elastic Cache for managing the real-time capabilities of the chat, and it works neatly.

Related

gRPC connection pooling on server side

I have a cluster of microservices to be hosted on Azure Kubernetes Service.
These microservices are .NET Core based and will
talk to on-premises services via gRPC
stream data using SignalR Core to client apps(Websockets)
The problem I can't find a good solution for is "How to persist gRPC" connections as pods are created and destroyed.
This seems like a very trivial problem for hosting microservices on a hybrid network. I would love to hear how others have addressed this issue.
Persistance of grpc would be difficult in such environment as pods are not persistant at all. I would suggest two approach to handle this scenario
Use/build a proxy between EKS and On Premises Service which can keep persistant connection open with on-premises service but connection to proxy can be added/removed as the pods are created/destroyed. This proxy can act as connection pool and provide higher throughput to on-premises service invocation.
Don't worry about the persistance of connection with on-premises services (treat this like a rdbms connection which can be created or destroyed on demand but has some cost in order to create new). This approach would work in case the pods are created or destroyed not too frequently.
I would suggest second approach in case the pods are not created/destroyed too frequently (few every hour) as it has less moving parts. But if pods are scaled up too frequently, approach one should be used.

Best solution to pass massive messaging spikes to AWS SQS

The app I'm working on is expected to face occasional spikes of incoming messages to be processed (Facebook webhook events). Live tests of this app hasn't been done yet but based on the experience of similar projects it's expected that these spikes can start sharply and hold at ~0.8-3k messages/sec for several hours. Beginning of the spike is predictable to the accuracy of several seconds-tens of seconds.
It's seems rational to pass these messages to some queue like AWS SQS and then process them at comfortable speed. If so, what would be the optimal solution for resending such message waves to SQS so that the listening app is always available, especially in the beginning of the spike (otherwise Facebook can probably show 503 error "Your webhook is down"):
hosting the listening app on AWS EC2 with a load balancer;
hosting the listening app on AWS Lambda (probably implementing some Lambda-warming measures like these)
other ideas? It would have been convenient if SQS could confirm subscription to Messenger webhooks so that Facebook would send those messages directly to SQS but that's unfortunately not possible due to "passive" nature of SQS.
Thanks in advance.
hosting the listening app on AWS EC2 with a load balancer
I think you can simplify it by going Serverless.
hosting the listening app on AWS Lambda (probably implementing some Lambda-warming measures
I don't think Lambda will be a good option because of 1000 concurrent executions limit, although it can be increased.
other ideas? It would have been convenient if SQS could confirm subscription to Messenger webhooks so that Facebook would send those messages directly to SQS but that's unfortunately not possible due to "passive" nature of SQS
I'd suggest using AWS API Gateway with AWS Service integration using SQS. You can configure
Facebook webhook events to go directly to your API Gateway REST endpoint. You can configure authentication and throttling as per your requirements in API gateway.
I like the architecture with a thin frontend application whose only responsibility is to accept the incoming request and immediately offload it to a queue or a stream. At the other end of the stream, there is a worker application that take care of the actually event processing.
other ideas?
Personally, I would use API Gateway mapped to Kinesis (or Kinesis Firehose) for the frontend application instead of EC2. Thus, I can rely on AWS to provide load balancing, autoscaling, OS patches, network configuration and so on. Moreover, Kinesis offers significant buffering capabilities so there is no need to resend the message spike. For the worker part of the application, it depends on what action needs to be performed. For short-lived operations, I recommend Lambda, but AWS also offers integration with EMR, Redshift, Elasticsearch and so on.

How to dynamically detect the web-server nodes in a load-balanced cluster?

I am implementing some real-time, collaborative features in an ASP.NET Web API based application using WebSockets and things are working fine when the app is deployed on a single web server.
When it is deployed on a farm behind a software (or hardware) load-balancer, I would like implement the pub-sub pattern to make any changes happening on one of the web servers invoke the same logic to check and push those changes via websocket to the clients connected to any of the other web servers.
I understand that this can be done if there an additional layer using RabbitMQ, Redis or some such pub/sub or messaging component.
But is there a way to use DNS or TCP broadcast or something that is already available on the Windows Server/IIS to publish the message to all the other sibling web-servers in the cluster?
No.
But you can use MSMQ instead of RabbitMQ, but still that's not really going to help as it's a queue and not pub/sub so ignore that.
If it's SignalR you're using there are plenty of docs on how to scale out like Introduction to Scaleout in SignalR
Even if it's not SignalR then you can probably get some ideas from there.

Microservice design with Kubernetes - API gateway, communication, service discovery and db issues

Recently I have been researching about microservices and kubernetes. All the tutorial and article I read online talks about general staff. I have several specific questions about building a microservices app on kubernetes.
API gateway: Is API gateway a microservice I built for my app that can automatically scale? Or is it already a built-in function of kubernetes? The reason I ask is because a lot of the articles are saying that load-balancing is part of the API gateway which confuse me since in kubernetes, load-balancing is handled by service. Also, is this the same as the API gateway on AWS, why don't people use the AWS API gateway instead?
Communication within services: from what I read only, there are Rest/RPC way and Message queue way. But why do people say that the Rest way is for sync operation? Can we build the services and have them communicate with rest api with Nodejs async/await functions?
Service Discovery: Is this a problem with kubernetes at all? Does kubernetes automatically figure out this for you?
Databases: What is the best practice to deploy a database? Deploy as a microservice on one of the node? Also, some articles say that each service should talk to a different db. So just separate the tables of one db to several dbs?
Is API gateway a microservice I built for my app that can
automatically scale? Or is it already a built-in function of
kubernetes?
Kubernetes does not have its own API-gateway service. It has an Ingress controller, which operates as a reverse proxy and exposes Kubernetes resources to the outside world. And Services, which load-balance traffic between Pods linked to them.
Also, Kubernetes provides an auto-scaling according to the resources consumed by Pods, memory usage or CPU utilization and some custom metrics. It is called Horizontal Pod Autoscaler, and you can read more about it here or in the official documentation.
Service Discovery: Is this a problem with kubernetes at all? Does kubernetes automatically figure out this for you?
Service Discovery is not a problem in Kubernetes, it has an entity called Services responsible for this. For more information, you can look through the link.
Your other questions refer more to the architecture of your application.

Consuming Amazon SQS (AMQP) from Azure

The need has come in which we have to consume data coming from a 3rd party in which they have an Amazon SQS instance setup on top of the AMQP protocol. They have given us the following:
queue name
user name
password
port
virtualhost
host
We are a cloud-born company in which we host everything in the Azure cloud, e.g. web services, web apps, databases, etc.
I would like to find out the following:
What "service" should I design or develop on from Azure that can consume messages from an Amazon SQS?
If Azure Service Bus supports AMQP 1.0 and Amazon SQS supports AMQP 0.9.3, can this be a plausible path?
I guess my question is more related on how to architect my solution. I know there are frameworks like RabbitMQ, but would like to avoid the VM path. If solutions like RabbitMQ are the way to go, can only the "consumer" pieces be utilized and not the "server" pieces of RabbitMQ implemented?
Any and all advice will be greatly appreciated.

Resources