I´m using Django and i have some questions.
I need a class to manage information in order to respond to user requests but my question is, can I do this without a database? I don’t need to save the information.
When a client makes a request does django instantiate a process for that client? instantiating this class once for each client? or will the classes instantiated in the server will be shared by all clients?
Maybe the questions might not be very clear but it’s kind of hard to explain.
Thank you very much in advance
You must have a database when running Django. Django relies upon having a database for its own internal use.
Whether or not you need to create models in that database depends upon what you’re gong to do.
To try and answer your question, no, Django does not create processes for clients. In a production environment, some number of Django processes are started to handle requests. Requests may create individual instances of classes which would be for an individual request. As a result, classes are shared between requests in a process, but the instances of those classes are not.
In general terms, it’s probably best to think of information being processed by a view as only existing for the duration of that request, unless it’s persisted externally to that view. (e.g. database, file, memcached, redis, etc)
I don’t know if this addressed what you’re really trying to determine here - if you could be more specific about what you’re trying to achieve, we may be able to be of more help.
Its a mini project which stream video to clients. with one client works well, the client can pause the video etc but with 2 clients if 1 pause the video pause in both. I´m reading about the django sessions in this moment
How are you trying to do this? If you’re trying to use StreamingHttpResponse, don’t. It’s not going to work well.
i´m using streamingHttpResponse indeed. In my case works well, the client can pause, go back and forward and back to live. This software as no intention to go public, its a tool for other project just to
But what is the other option instead of httpstreamingresponse?
Are you currently using
runserver for this? That would be part of the problem.
If you know the number of users is going to be very small (number of concurrent users < number of CPUs on the host system), then you could set this up in a production-style deployment using gunicorn where it is running separate processes for each user.
But for any load larger than that, you’ll want to use something other than Django to serve the videos. It’s really not designed to do that.
This software will only be used to record some kind of video, at maximum 2 or 3 users. I´m currently using runserver.