小编sur*_*urX的帖子

Django,每秒低的请求与gunicorn 4工人

我想知道为什么我的django网站(gunicorn 4工作人员)在重载下很慢,我做了一些分析http://djangosnippets.org/snippets/186/没有任何明确答案所以我从头开始一些负载测试ab -n 1000 -c 100 http://localhost:8888/

一个简单的Httpreponse("hello world")没有中间件==> 3600req/s

带有中间件的简单Httpreponse("hello world")(缓存会话,缓存身份验证)==> 2300req/s

一个简单的render_to_response只打印一个表单(缓存模板)==> 1200req/s(响应时间除以2)

一个简单的render_to_response,包含50个memcache查询==> 157req/s

Memcache查询应该比这快得多(我正在使用PyLibMCCache)?模板渲染是否与此结果一样慢?

我尝试了不同的分析技术但没有任何成功.

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 46936
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 400000
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority …
Run Code Online (Sandbox Code Playgroud)

django memcached django-templates gunicorn

10
推荐指数
1
解决办法
2484
查看次数

401未经授权使用oauth-python-twitter

我正在尝试使用http://code.google.com/p/oauth-python-twitter在appengine(python)中实现"twitter oauth" .

我使用以下代码将用户重定向到twitter:

twitter = OAuthApi(CONSUMER_KEY, CONSUMER_SECRET)  
request_token = twitter.getRequestToken() 
response.set_cookie('request_token', request_token.to_string()) 
signin_url = twitter.getAuthorizationURL(request_token)   
return redirect_to(signin_url) 
Run Code Online (Sandbox Code Playgroud)

用户成功重定向,但当他在我的应用程序中返回时,我收到以下错误:HTTP错误401:未经授权

  File "/base/data/home/apps/app/controllers/users.py", line 46, in authenticate
    access_token = twitter.getAccessToken()    
  File "/base/data/home/apps/app/lib/python/oauthtwitter.py", line 183, in getAccessToken
    token = self._FetchUrl(url, no_cache=True)
    ......
  File "/base/python_dist/lib/python2.5/urllib2.py", line 506, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
Run Code Online (Sandbox Code Playgroud)

当我尝试获取访问令牌时发生错误.

request_token = request.cookies['request_token']
token = oauth.OAuthToken.from_string(request_token)  
twitter = OAuthApi(app_globals.CONSUMER_KEY, app_globals.CONSUMER_SECRET, token) # everything works good
access_token = twitter.getAccessToken()  # then, i receive the error.
Run Code Online (Sandbox Code Playgroud)

任何的想法?谢谢!

twitter oauth

5
推荐指数
1
解决办法
2691
查看次数

标签 统计

django ×1

django-templates ×1

gunicorn ×1

memcached ×1

oauth ×1

twitter ×1