More Related Content Similar to Google Developer Day 2010 Japan: Google App Engine についての最新情報 (松尾貴史) (20) More from Google Developer Relations Team (14) Google Developer Day 2010 Japan: Google App Engine についての最新情報 (松尾貴史)6. Task Queue の強化
queue.yaml で total_storage_limit が指定できるようにな
りました。下記のように記載します。
total_storage_limit: 100G
queue:
- name: default
rate: 50/s
Task Queue で使えるストレージ容量が設定できます。B
は byte, K は kilobyte, M は megabyte, G は gigabyte, T
は terabyte です。デフォルト値は 100M です。
12. 高速イメージ配信 Sample
ハンドラー - フォームとサムネイルを表示
class MainHandler(webapp.RequestHandler):
def get(self):
upload_url = blobstore.create_upload_url('/upload')
self.response.out.write("""<html><body>
<form action="%s" method="POST" enctype="multipart/form-data">
Title: <input name="title"><br>
Upload File: <input type="file" name="file"><br>
<input type="submit" name="submit" value="Submit">
</form>""" % upload_url)
album_images = AlbumImage.all().order("-created_at").fetch(5)
for album_image in album_images:
self.response.out.write(album_image.title + "<br>")
self.response.out.write('<a href="%s"><img src="%s"></a><br>'
% (album_image.original_image_url,
album_image.thumbnail_url))
self.response.out.write("</body></html>")
13. 高速イメージ配信 Sample
ハンドラー - アップロードされた画像を処理
class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
def post(self):
# 'file' is file upload field in the form
upload_files = self.get_uploads('file')
blob_info = upload_files[0]
original_image_url = images.get_serving_url(str(blob_info.key()))
uploaded_image = AlbumImage(
title=self.request.get("title"),
original_image_url=original_image_url,
thumbnail_url=original_image_url+"=S320"
)
uploaded_image.put()
self.redirect('/')
15. 1000件制限
カウントと fetch の limit で 1000 以上指定可能
q = MyModel.all()
number = q.count(100000)
entries = q.fetch(100000)
システムの30秒制限にてタイムアウトする可能性は
あります
20. Multitenancy
Google Apps のドメインで namespace を分けたい場合のパターン
appengine_config.py にて下記のようにします。
from google.appengine.api import namespace_manager
# Called only if the current namespace is not set.
def namespace_manager_default_namespace_for_request():
# The returned string will be used as the Google Apps domain.
return namespace_manager.google_apps_namespace()
appengine_config.py ?
22. appengine_config.py
例えば mylib.py を appengine_config.py 対応にするには
mylib.py:
from google.appengine.api import lib_config
config_handle = lib_config.register(
'mylib',
{'do_something': lambda obj: obj})
def do_something(obj):
return config_handle.do_something(obj)
25. Multitenancy
my_namespace_manager.py
import os
from google.appengine.api import namespace_manager
current_namespace = ""
test_namespace = ""
pattern = "%s--%s"
def _set_namespace():
if test_namespace:
namespace_manager.set_namespace(pattern % (test_namespace,
current_namespace))
else:
namespace_manager.set_namespace(current_namespace)
def _initialize():
if not namespace_manager.get_namespace():
initialize("")
続く
26. Multitenancy
(続き)
def initialize(namespace):
global test_namespace, current_namespace
current_namespace = namespace
test_namespace = ""
def get_namespace():
return current_namespace
def set_namespace(namespace):
global current_namespace
_initialize()
current_namespace = namespace
_set_namespace()
def set_test_namespace(namespace):
global test_namespace
_initialize()
test_namespace = namespace
_set_namespace()
28. 知らないかもしれない注意点
平均 1000ms で Response を返すアプリケーション
のみ AutoScale します。
実際には 800ms を目指してください。
400ms くらいだと理想的です。
Query per minutes limit
課金をオンにしたアプリケーションの最大 qpm
は 500 qps のスパイクをさばける程度に制限さ
れています。
それ以上必要なら相談してください。