简体   繁体   English

有没有办法对本地appengine开发服务器强制执行30秒限制?

[英]is there any way to enforce the 30 seconds limit on local appengine dev server?

Hey, i was wondering if there is a way to enforce the 30 seconds limit that is being enforced online at the appengine production servers to the local dev server? 嘿,我想知道是否有办法强制执行在appengine生产服务器上在线执行到本地开发服务器的30秒限制? its impossible to test if i reach the limit before going production. 如果我在上市前达到极限,就无法测试。

maybe some django middlware? 也许一些django middlware?

You could write (and insert in the WSGI stack) a useful piece of WSGI middleware which uses a threading.Timer which logs the fact that the transaction has exceeded 30 seconds (and of course calls cancel on the timer object on the way out, as there's nothing to log in that case). 您可以编写(并在WSGI堆栈中插入)一个有用的WSGI中间件 ,它使用threading.Timer来记录事务超过30秒的事实(当然,在出路时调用取消定时器对象,在那种情况下没有什么可以登录的)。

I'd do it at WSGI level, not Django level, (a) because I'm more familiar with WSGI middleware and (b) because it's a more general solution (it can help a Django web app, but it can also help a web app using any other framework -- WSGI's use is guaranteed by App Engine, whatever framework you decide to lay on top of it). 我是在WSGI级别,而不是Django级别,(a)因为我更熟悉WSGI中间件和(b)因为它是一个更通用的解决方案(它可以帮助Django Web应用程序,但它也可以帮助一个使用任何其他框架的Web应用程序 - 无论您决定在其上放置什么框架,都可以通过App Engine保证WSGI的使用。

You'll need to tweak the "30 seconds" a bit to calibrate, because of course the power, available RAM, disk speed, etc, of your development machine, can't just happen to be exactly identical to Google's, and also many subsystems (esp. the storage one) have very different implementations "locally on the SDK" versus "on Google's actual servers" and in any given case may happen to be substantially slower (or maybe faster!-). 您需要稍微调整“30秒”以进行校准,因为您的开发机器的功率,可用RAM,磁盘速度等当然不能恰好与Google的完全相同,而且很多子系统(尤其是存储系统)在“本地SDK”与“在Google的实际服务器上”具有非常不同的实现,并且在任何给定的情况下可能恰好更慢(或者更快! - )。

Given the considerations in the previous paragraph it might actually be more helpful to have the middleware simply always log the transaction's total elapsed time -- this way you can watch for transactions that (while they may terminate within 30 seconds on your development server) are taking comparable time (say 15 or 20 seconds or more), especially if they have multiple storage transactions that might slow them down on the real production servers/ 考虑到前一段中的考虑因素,让中间件始终记录事务的总耗用时间实际上更有帮助 - 这样您就可以监视(当它们可能在开发服务器上30秒内终止时)的事务可比时间(例如15或20秒或更长时间),特别是如果它们有多个存储事务可能会减慢它们在真实生产服务器上的速度/

It's possible , as Alex demonstrates, but it's not really a good idea: The performance characteristics of the development server are not the same as those of the production environment, so something that executes quickly locally may not be nearly as quick in production, and vice versa. 正如Alex所说,这是可能的 ,但这并不是一个好主意:开发服务器的性能特征与生产环境的性能特征不同,因此在本地快速执行的东西在生产中可能不会那么快,副反之亦然。

Also, your user facing tasks should definitely not be so slow as to approach the 30 second limit. 此外,面向用户的任务绝对不应该太慢,以至于接近30秒的限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AppEngine本地开发服务器上的Braintree SDK SSLCertificateError - Braintree SDK SSLCertificateError on AppEngine local dev server 在本地开发服务器上的Google Appengine后端日志记录 - Google Appengine backend logging on local dev server AppEngine功能可在本地开发服务器上使用,但不能在实时Web服务器上使用 - AppEngine feature working in local dev server but not on live web server AppEngine dev_appserver.py未显示任何输出 - AppEngine dev_appserver.py not showing any outputs 有什么方法可以取消删除Appengine中的索引? - Is there any way to cancel deleting an index in Appengine? ImportError:无法使用AppEngine开发服务器导入名称SignedJwtAssertionCredentials - ImportError: cannot import name SignedJwtAssertionCredentials using AppEngine dev server 在appengine上查询datetime.datetime的行为与开发服务器的帮助不同! - Querying datetime.datetime on appengine acts different then dev server help! 无法在dev_server上运行appengine-admin - cannot run appengine-admin on dev_server 升级到appengine dev server 1.7.6后导入simplejson时出错 - Error importing simplejson after upgrading to appengine dev server 1.7.6 python运行时中Appengine开发服务器上的模块初始化错误 - Module initialization error on appengine dev server in python runtime
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM