Giter Club home page Giter Club logo

Comments (7)

vishalanandl177 avatar vishalanandl177 commented on June 14, 2024

from drf-api-logger.

asifkhan69 avatar asifkhan69 commented on June 14, 2024

Hi Ashif, DRF API Logger should work the same as in your development server. Maybe you forget to migrate after adding DRF API Logger in production. Does the production server use different settings? (example: production_settings.py, development_settings.py, in some projects I've seen completely different settings.) Please share DEF API Logger settings you used. Regards, Vishal Anand, Technical Lead, LinkedIn https://www.linkedin.com/in/vishal-anand-530ba0b5/ | M: +91-8009417767

On Sat, Mar 27, 2021 at 4:48 PM Asif Khan @.***> wrote: Everything is perfectly working in development environment. All my APIs that I am using POSTMAN desktop application is logging in drf_api_logger model. In nutshell all is working perfect as what I am looking. But once I transfer my code to production environment drf_api_logger is not logging any API calls from POSTMAN from both version desktop and web base POSTMAN. I tried by looking options in drf_api_logger documentation, nothing works. One thing I noticed the difference in development and production is of "http" vs "https". Can you please advice how I can make drf_api_logger to work for my production environment. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#12>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7SDTGBFFLJL5YFLZD6LTDTFW5HZANCNFSM4Z42A6ZQ .

Hi Vishal,

Thanks for your response. I have redeploy my code again on production with one of changes that I have done in your code to customize drf_api_logger for my specific purpose. My project structure is SAAS based so I have add one orgcode in the model of drf_api_logger to control all APIs at organisation level and same I have to done in admin.py to shows api of logged in user of that organisation only.

So I correct it and it is working now. Thanks again for your response and it is great support for my project.

from drf-api-logger.

hellvix avatar hellvix commented on June 14, 2024

I don't think this has to do with HTTPS. I have 3 environments: development, staging and production. Only production has HTTPS and yet it fails both in staging and production. Development works fine.

The database has the correct tables, but when I check there are no entries.

My environments are very similar to each other. The only main difference I can think of is Nginx, which is a common feature between staging and production. Which application gateway did you use for your tests, @asifkhan69?

from drf-api-logger.

vishalanandl177 avatar vishalanandl177 commented on June 14, 2024

Try setting headers in Nginx.
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass .....
.....

from drf-api-logger.

hellvix avatar hellvix commented on June 14, 2024

That is not the problem. I did some debugging and found out the following:

Since you create an instance of Queue for each thread, filling each queue will take longer. The chances of having the same user filling up the same queue is ~1/t.

I had the default DRF_LOGGER_QUEUE_MAX_SIZE, having a total o 4 threads for the process. This means that in theory, it can take up to 200 entries to bulk insert some 50 entries.

I suggest adding to the documentation that the real Queue size is multiplied by the amount of threads that you configure for the gateway.

Additionally, the reason why we could not see that in development is because the Django development HTTP server has only one thread.

Another thing: I am not sure if DRF_LOGGER_INTERVAL is working as intended. I made several tests where the queue length was < DRF_LOGGER_QUEUE_MAX_SIZE and it did not work. I have not debugged this thoroughly though.

from drf-api-logger.

vishalanandl177 avatar vishalanandl177 commented on June 14, 2024

If you are using gunicorn with workers in production, each worker (process) is going to have its own DRF API Logger thread.
Based on the server load, gunicorn will assign the request to any worker. Each worker is going to have a unique request always.
So there is no chance that the same request will go to DRF API Logger thread.
I'm already having millions of records in the logs, never faced any problem related to threads or queues.

I'll check the rest of the other queries.

from drf-api-logger.

hellvix avatar hellvix commented on June 14, 2024

I didn't express myself correctly. I meant to say the chances of having the same user filling up one queue is the probability I mentioned, since two requests might not be necessarily be added to the same queue.

There aren't that many API requests in my system, so that's probably why I caught this problem. If you have millions of requests, the queue may get filled up before the countdown from DRF_LOGGER_INTERVAL ends. I did a test and this is exactly what happened.

To reproduce this problem, try to insert only a couple of requests to the queue and wait. It is never inserted to the database.

I am using uwsgi, by the way.

from drf-api-logger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.