Django instance runs under Google App Engine

After thinking a lot about how to make a fast and scalable web application, I almost decided to go for a combination of Google App Engine, Python + Django, and app-engine-patch. But I came across a comment in the frequently asked questions about using app-engine-patchWhich made me think that maybe the combination is not quite as mature as I thought: it might take a few seconds for the Django instance to load (1-4, according to the FAQ). This might not be a problem if there is some persistence from the request to request, but it seems that when there is no steady traffic, the Django instance will shut down after a few seconds. If the system is not called every second or so, any incoming request will take seconds (!). This is unacceptable. As a quick fix (ugly I know), I thought about having an external machine make a dummy request to the framework every second to keep it alive.

Do you agree with this? Do you have a different approach?

Another doubt about what happens if there is enough traffic to go from one server n to n + 1, will the request ask for seconds because a new Django instance needs to be started? or is google infrastructure not working this way? I confess my ignorance. problem.

Help!

+2


source to share


5 answers


Yes, long startup times are a caveat to using a framework with a lot of code. There is currently no way around them other than using a lighter weight framework (like the built-in webapp framework).

Polling your application is not recommended: it will use a quota and does not really guarantee that real user requests will end up in the same instance as your polling requests, since applications run in multiple instances.



Fortunately, there is a simple solution: Get Popular! The more popular your application is, the less frequent instance restarts are required, and the lower the proportion of users, it affects.

+3


source


I respect what you are trying to do, but it sounds a bit like a pre-mature optimization to me. The py + django package you are discussing is recommended by Google until it upgrades to "real" django, so I can't imagine this is a bad thing. It is also not that hard to test the performance of what you are talking about, so I suggest you do that and run a few metrics on it before making your final decision. That way you have the math to back it up when someone else starts complaining;)



+1


source


They also mention in the FAQ that using the zipped version of Django will help load times, although I guess it could be long. Regarding your original question, I would agree with others that polling your application is probably not a good idea because it probably won't solve your problem, because Google might propagate your queries across many machines, etc. Etc.

+1


source


Also, it seems to me (but Nick can correct me here if I'm wrong) that if you're using embedded Django (.97 or 1.0), loading is less of a problem. Logically, I would say that they keep the embedded libraries in memory for everyone, or share that cached code between instances. But I don't know for sure.

0


source


See Takashi Matsuo Comparison . Basically, for the simplest app-engine-patch that does almost nothing, it claims about ~ 1s versus ~ 350ms for webapp + Django templates.

Seems like longer than 1s for our app, but Takashi just tried the simplest app he could think of.

0


source







All Articles