这是我的情景:
当用户登录我的网站时,我会为给定用户排队一堆任务(通常每个任务需要100个msecs,每个用户有100个任务).这些任务排队到默认的Celery队列,我有100个工作人员正在运行.我使用websockets来显示用户在后端完成任务时的实时进度.如果我只有1或2个用户活跃,那么生活是美好的.
现在,如果我有几个并发用户登录到我的站点,后面的用户排在初始用户后面并且他们的任务会饿死(因为所有任务都进入同一个队列).我的想法是为每个用户创建一个动态队列以确保公平.但是根据Celery文档(http://docs.celeryproject.org/en/latest/userguide/routing.html#defining-queues),我似乎需要静态定义队列.
关于在我的场景中使用芹菜的最佳实践的任何建议?
我在CentOS 6.3上使用Python 2.7,Apache + mod_wsgi运行
当我在localhost时,事情很好.但是,当我在Azure中的vm上运行代码时,我看不到会话信息是否跨页面持久存在.
基本上在我看来,我有类似的东西:
@frontend.route('/')
def index():
session['foo'] = 'bar'
print session['foo']
return redirect(url_for("frontend.page2"))
@frontend.route('page2')
def page2():
print session
Run Code Online (Sandbox Code Playgroud)
打印输出是:
bar
<SecureCookieSession {}>
Run Code Online (Sandbox Code Playgroud)
我对apache的wsgi配置是:
WSGISocketPrefix /var/run/wsgi
<VirtualHost *:80>
ServerName example.com
ServerAlias example.com
WSGIDaemonProcess myproj threads=5 processes=5
WSGIScriptAlias / /home/mydir/myproj/apache/myproj.wsgi
<Directory /home/mydir/myproj>
WSGIScriptReloading On
WSGIProcessGroup myproj
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我有secret_key集:
app.secret_key = os.urandom(24)
Run Code Online (Sandbox Code Playgroud)
我尝试过设置SERVER_NAME,但它没有帮助:
app.config['SERVER_NAME'] = 'example.com'
Run Code Online (Sandbox Code Playgroud)
关于我如何调试更多的任何想法?
谢谢!