RabbitMQ for http/https request queuing in Django - django

One of my clients wants to use RabbitMQ for request queuing on his Django DRF powered web app. the app is simple just saving and listing information with attachments (over S3 storage) with high traffic.
As I know RabbitMQ acts as message broker which can be helpful while doing long tasks/sending emails/ generating PDFs.
I am curious to know that in my scenario can I use rabbitMQ? and if yes then what will be the advantages of using it.

Related

How can I make a client server show updated data without send request?

I design a application for a restaurant one of the features is that the user can make an order online and the oreder status is pending until the restaurant cashier or restaurant admin staff convert status by accept or refuse
so i wanna send to client a notification if there is pending orders or something that the admin staff or cashier know that there is an pending order created now without need to update or refresh the client page
so my question is how i make a backend server send to client browser notification without the client need to refresh the page or send request to backend server
i use django rest framework
I hear about websocket and Django channels
Also i hear about SSE
Also i read about client freamwork send requests every n minute to update the page
I need to know what the best approach to implement this and if there is another technology and what is best for server if there is a lot of loading or the application used by millions of users
For example - you can implementig full-state service on nodejs + express + socket.io or asp.net + signalR. Client connecting to your service via websocket if customer open page where there order status. This solution will allow scale only service if connecting many client, also you should think over communication between service and general app on django, for example use rabbit or kafka or other. Also your can use this service for new realtime features

NextJs in Amplify. Easiest way of creating a pubsub comunition betwen server and client?

I see that we can create a websocket using API gateway and lambda, but is there a way of creating client-server pub sub system using only resource amplify offer when working with nextJS?
The best solution I thought is using app sync to make the client listen to changes in the database, then the backend updates some field in the User table(such as lastEvent: Event) to send it to the user. Of course, we could we Server-Sent Events or Http Long Pooling, but is not cost-efficient to force lambda functions to keep alive. Is there a better way to do this?

Log http requests in db table with django and tastypie without increase response time

I have android app on which my django server is sending some push notifications using firebase cloud messaging. As soon as client received the notifications, it makes a GET request to my API written using Tastypie.
I want to somehow store this GET request in my Log table so that I can ensure that my android app is working fine and make right requests on receiving notifications from server.
On one of the answers, I read that it can be achieved by overriding the dispatch function for Model Resource in tastypie. Could this logging be achieved without overriding the dispatch because it can potentially increase the response time.

Service Worker: handle requests when offline to send them when online

I have a chat web application and I want it to work offline. For this I use progressive web apps features (Service Workers) to use cache to get the shell app and the messages already loaded.
What I want to do is to be able to make a post message when I'm offline and let the service worker handle the connection issues (i.e.: keep the message somewhere till where are offline and as soon as we are online send the Post message).
I want to use Service Worker because I also want to send the message if the user as left the web app after posting a message with no connection.
What is the best API to use for this?
I saw the background sync API but it is not standard and it doesn't seem to be updated for almost 2 years.
If there is a way to do this in a manner that the client (the web app) is totally unaware of this mechanism it would be cool.
What I mean by that is I would like my app just do a
fetch("/message", {method : "post", body : {content : "hey there"})
And then the Service Worker just intercept the fetch, if we are online then it just send the fetch, but if we are offline it "wait" for the connection to be up again and then send the post.
I wonder if there is an event listener, available in the service worker, that will be activated when the connection change from offline to online. This way I should be able to store the request in indexDB when offline and then send the post when online.
I saw the navigator.onLine but it is not an event :(
Based from this post, you may use a Service Worker in running the app in the background either via its push event handler (triggered via an incoming push message), or via its sync event handler (triggered by an automatic replay of a task that previously failed).
You may check the Offline Storage for Progressive Web Apps documentation for storing data offline:
For URL addressable resources, use the Cache API (part of service workers).
For all other data, use IndexedDB (with a promises wrapper).
You can cache static resources, composing your application shell (JS/CSS/HTML files) using the Cache API and fill in the offline page data from IndexedDB.

Response from Web Server is dependent on ZeroMQ (0MQ) RES

In lightweight SOAs I've seen many designs that have a Web Server receives Client requests and send responses that are dependent upon responses from other services. I've also seen this done incorrectly resulting in unacceptable latency issues.
For Example:
Assume:
We have 1 Web API Server and 1 Service A API.
Web Server performs basic User Auth and other User functionality.
Service A performs database operations.
ZeroMQ (ZMQ, 0MQ, etc) REQ/RES user for service messaging
Work Flow:
Client makes request to Web API Server API.
Web Server performs database operations (auth etc).
Web Server makes request to Service A API.
Service A performs database operations.
Service A responds with data to Web Server.
Web Server receives response and sends response to client.
This pattern is different from the typical offline message queue processing work flow. As well it includes a request to a single service (A)
While trying to maintain separate system services is this a correct usage pattern with ZeroMQ?
I'm trying to figure out if ZeroMQ can be used to make service requests and send the results to client web service requests without significant performance issues.