Google App Engine Node.js本地开发 [英] Google app engine nodejs local development
问题描述
是否有一种方法可以在本地运行我的nodejs应用程序,以便我可以模拟在生产App Engine中运行的应用程序而无需进行部署?由于某些原因,与本地主机相比,我的应用在Google App Engine中的行为有所不同.
每当我进行更改以查看是否存在错误时,我都厌倦了将应用程序部署到Google App Engine的过程.
在您的本地系统和真实的GAE基础架构上,您将永远不会完全获得相同的行为.一次是因为您运行的基础架构不同:操作系统,硬件和网络性能/功能,您的应用可能正在使用的实际与SDK模拟的Google API和服务的性能/功能,时间安排等.>
一些示例(它们来自标准的env GAE,是的,但是从根本上讲是相同的想法):
- FetchOptions withLimit()不会减少查询执行时间(Google App Engine)
- 数据存储区提取VS fetch(keys_only = True)然后get_multi
- Ndb的一致性强且写入频繁
您应该调查这些差异-非常欢迎您在SO上就其中的每个问题提出疑问.
通常,您会发现两类差异:
-
预期的性能差异,但它们可能会发现代码中的实际问题:竞争条件,错误的时序假设等
-
功能差异-查找要在GAE而非本地进行测试的常规区域.
例如,我(艰难地)了解到,SDK数据存储区模拟器无法模拟真实数据存储区中的竞争逻辑-虽然我的应用在本地运行良好,但在GAE上,由于竞争,它的爬坡非常糟糕,我不得不重新编写逻辑的一个很好的部分来解决它.请参见 Google App Engine中的竞争问题
Is there a way to run my nodejs application locally so that I can simulate my application running in production App Engine without deploying it? For some reason my app behaves differently in the Google App Engine compared to my localhost.
I am getting tired of deploying my application to Google App Engine every time I make a change just to see if there's a bug.
You'll never get exactly the same behaviour on your local system and on the real GAE infrastructure. For once simply because the infrastructure on which you're running is different: OS, hardware and network performance/capabilities, performance/capabilities of the actual vs SDK-simulated google APIs and services your app may be using, timing, etc.
A few examples (they're from the standard env GAE, it's true, but it's fundamentally the same idea):
- FetchOptions withLimit() does not reduce query execution time (Google App Engine)
- Datastore fetch VS fetch(keys_only=True) then get_multi
- Why does Google Cloud SQL (using JDBC) take longer to insert records from Google App Engine than from my personal computer?
- Ndb strong consistency and frequent writes
You should investigate the differences - you're more than welcome to ask questions about each one of them right here, on SO.
In general you'll find the differences falling in 2 categories:
plain performance differences, expected, but they may uncover actual problems in your code: race conditions, wrong timing assumptions, etc
functional differences - to find general areas where you want to perform testing on GAE rather than locally.
For example I learned (the hard way) that the SDK datastore emulator doesn't emulate the contention logic from the real datastore - while locally my app was running fine, on GAE it was crawling miserably due to contention, I had to re-write a good portion of the logic to address it. See Contention problems in Google App Engine
这篇关于Google App Engine Node.js本地开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!