0
votes

I have deployed a service.
It is served by nginx, uwsgi, django, pgpool, postgresql stack.

The page that has no db access is no problem.
However, the page that has some data from postgres is tpo slow.

Actually, db query time is quite fast. under 10 ms.

But result to client is over the 120000 ms

  • uwsgi log

    [pid: 2056|app: 0|req: 4/10] 211.207.245.120 () {44 vars in 1116 bytes} [Thu Jul 19 00:53:31 2012] GET /account/admin/cb_main/invitationuser/ => generated 38606 bytes in 122126 msecs (HTTP/1.1 200) 8 headers in 373 bytes (1 switches on core 0)

My settings are below
Please check my settings and solve my problems

  • nginx settings

    upstream cuying {
            ip_hash;
            server 127.0.0.1:9001;
    }
    
    server {
            listen  8080;
            root    /home/cuying_mgr/;
            client_max_body_size 20M;
            server_name     cuying.com;
            location / {
                    uwsgi_pass cuying;
                    include uwsgi_params;
                    uwsgi_read_timeout 120;
                    uwsgi_send_timeout 120;
            }
    }
    
  • uwsgi settings

    chdir=/home/cuying_mgr/develop/virenv/cuying/cuying
    processes=2
    workers=8
    enable-threads=true
    socket=127.0.0.1:9001
    module=cuyingProject.wsgi:application
    master=True
    pidfile=/tmp/cuying-master.pid
    vacuum=True
    close-on-exec=True
    max-requests=3000
    post-buffering=8192
    socket-timeout=120
    limit-post=20480000
    virtualenv=/home/cuying_mgr/develop/virenv/cuying
    daemonize=/var/log/uwsgi/cuying.log
    

Please help me out!
It's too slow.....

1
Can you give us the code for the page that's accessing the database? - girasquid
actually it is occurred in admin tools. - shchoi
it have just two fields and have 500 data. it needs 12s to get first page with 100 data - shchoi
2012-07-18 16:34:04 UTC LOG: duration: 2.556 ms statement: SELECT "cb_main_invitationuser"."id", "cb_main_invitationuser"."email", "cb_main_invitationuser"."is_sent" FROM "cb_main_invitationuser" ORDER BY "cb_main_invitationuser"."id" ASC LIMIT 100 ==> it is db log.. just under 3ms - shchoi
Can you give us the code for the admin configuration for that page, and the model? If the query in the database takes 3ms and the page takes 12s to send a response, the problem is somewhere else. - girasquid

1 Answers

0
votes

Use profiler to find out the slowest point while processing request. It looks like the problem was not caused by postgresql or uwsgi things.

See ProfilingDjango wiki page.