Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GAEによるPythonWEBアプリケーションの高速開発
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
shimakaze-git
August 30, 2019
Programming
0
3.1k
GAEによるPythonWEBアプリケーションの高速開発
shimakaze-git
August 30, 2019
Tweet
Share
More Decks by shimakaze-git
See All by shimakaze-git
DjangoとFastAPIによる 実践認証技術
shimakaze_soft
0
900
フロントエンドとバックエンドのコミュニケーションをスムーズにするスキーマ駆動開発
shimakaze_soft
2
550
クリーンアーキテクチャのリポジトリパターン - Pythonでの実装
shimakaze_soft
1
6k
lt20221030.pdf
shimakaze_soft
0
180
Dependabotを使って 運用しているおはなし
shimakaze_soft
0
2.2k
DjangoCongressJP 2019/2020 & 今年にPyConJP初登壇できたはなし
shimakaze_soft
0
450
FlaskとDjango以外のAPI開発の選択肢
shimakaze_soft
0
510
Python で Dependency Injection(DI) をやるには?
shimakaze_soft
1
3.7k
FalconAPI開発にいいよ!
shimakaze_soft
0
740
Other Decks in Programming
See All in Programming
DevinとClaude Code、SREの現場で使い倒してみた件
karia
1
1.1k
Nostalgia Meets Technology: Super Mario with TypeScript
manfredsteyer
PRO
0
100
どんと来い、データベース信頼性エンジニアリング / Introduction to DBRE
nnaka2992
1
330
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
360
飯MCP
yusukebe
0
210
脱 雰囲気実装!AgentCoreを良い感じにWEBアプリケーションに組み込むために
takuyay0ne
3
380
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
490
車輪の再発明をしよう!PHP で実装して学ぶ、Web サーバーの仕組みと HTTP の正体
h1r0
2
300
ロボットのための工場に灯りは要らない
watany
11
3.1k
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
770
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.4k
ふつうのRubyist、ちいさなデバイス、大きな一年 / Ordinary Rubyists, Tiny Devices, Big Year
chobishiba
1
500
Featured
See All Featured
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
110
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
180
Balancing Empowerment & Direction
lara
5
960
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
200
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.5k
Making Projects Easy
brettharned
120
6.6k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
320
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
110
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
160
Transcript
@shimakaze_soft GAE によるPythonWEB アプリケー ションの⾼速開発 shimakaze_soft WEB エンジニア勉強会 2019-08-30 shimakaze-git
BackEnd Enginner しまかぜsoft (@shimakaze_soft) 株式会社 Pasona JOB HUB に所属 DjangoCongressJP
スタッフ バックエンドエンジニア( 主にDjango を使⽤) 少しだけインフラエンジニアも兼務 BtoC 向けのサービスを開発 shimakaze_soft ( ⼤島和輝) お前、誰よ?
・Google App Engine を⽤いてのPython の WEB アプリケーションの⾼速な開発 今⽇話すこと
・Django を⽤いてのGAE による開発⽅法をお話し ます ・GAE のStandard( スタンダード) 環境を使⽤しま すが、Flexible( フレキシブル)
は使いません 今回話すことの注意点
・Python は軽量プログラミング⾔語の⼀種 ・巷では機械学習やデーター分析系で有名 ・WEB アプリケーションでも普及 ・Django はPython の中では有名なWEB フレームワーク -
instagram - connpass Django とは何か? ついでにPython について
・GCP のサービスの⼀つで、インフラ上でアプリケー ションを実⾏できるPass ・Heroku みたいなもの、AWS でいうならECS ・単純にアプリケーションをアップロードするだけでア プリケーションを実⾏可能 Google App
Engine とは
・AWS のECS よりも価格が安い ・Node 、Java 、Ruby 、C# 、Go 、Python 、PHP
など のあらゆる⾔語ををサポート ・Standard とFlexible の⼆種類がある Google App Engine の特徴 (1)
・Nginx みたいなWEB サーバーが不要になる ・デプロイすると⾃動でstackdriver logging にログを 流す Google App Engine
の特徴 (2)
Google App Engine Flexible 環境とStandard 環境 の違い
Flexible 環境 ・ローカルディスクの書き込み可能 ・Dockerfile によるカスタマイズが可能 ・SSH 接続が可能 Standard 環境 ・⼀部、機能が制限されている
・ローカルディスクの書き込みが不可能 ・インスタンスの起動時間が⼀瞬 ・SSH 接続ができない
Google App Engine 実践編
$ django-admin startproject sample_django $ cd sample_django $ python manage.py
migrate $ touch requirements.txt $ vim requirements.txt # django を導⼊ django==2.2.3 Django のセットアップ (1)
$ vim config/settings.py # STATIC 関連の設定 STATIC_URL = '/static/' STATIC_ROOT
= os.path.join(BASE_DIR, 'static') $ python manage.py collecstatic Django のセットアップ (2)
$ touch main.py $ vim main.py # GAE で読み込むためのファイルを設定する from
sample_django.wsgi import application app = application Django のセットアップ (3)
app.yaml AppEngine の動作に必ず必要な基本的なファイル dispatch.yaml cron.yaml ルーティングルールを細く設定する設定ファイル バッチ関連の設定ファイル、設定したスケジュールの 時間帯に特定のURL に対してリクエストを送る Google
App Engine 各種設定ファイル
動かすランタイムとバージョンの指定 runtime: python37 構成ファイルの書き⽅ (1) app.yaml runtime の設定 python37
handlers: - url: / script: auto - url: /static static_dir:
static/ 構成ファイルの書き⽅ (2) app.yaml handlers のルーティングの設定
handlers: - url: / script: auto (auto にするとmain.py を⾃動で選択) -
url: /static static_dir: static/ 構成ファイルの書き⽅ (2) app.yaml handlers のルーティングの設定
env_variables: TEST_ENV: 0 構成ファイルの書き⽅ (3) app.yaml env_variables 環境変数の設定
・requirements.txt というのはPython のパッケージ 管理ファイル ・以下のコマンドがGAE 内で $ pip install -r
requirements.txt requirements.txt の内容を元に⾃動でパッ ケージをインストールする
・requirements.txt にgunicorn を加えなくてもいい gunicorn はDjango では定番のアプリケーションサーバ GAE にgunicorn が最初から⼊っている
以下のコマンドでデプロイ $ gcloud app deploy -q gcloud app deploy によるデプロイ
引数を指定することでyaml ファイルを選択できる $ gcloud app deploy staging-app.yaml gcloud app deploy
によるデプロイ
https://[ バージョン]-dot-[ プロジェクトID].appspot.com ⾃動でSSL 付きのドメインが振られる
Google App Engine 使って後悔したこと
・10 分以上かかることも結構ある ・⼤した規模じゃないアプリでもStandard で 3 分ぐらいかかる デプロイ遅い( フレキシブルだと最悪)
・デフォルトで設定されているdefault アプリケー ションのみにドメインを切れる ・それ以外のアプリケーションはサブドメインのみ GAE 内でドメイン⼀つしか切れない
WebSocket が未対応
⾼速開発とか⾔っているけど デプロイ遅くて結構ストレス貯まります
・Nginx の設定などが不要 ・インフラの管理が圧倒的に楽 ・結構癖があって制限がある ・デプロイ遅い まとめ
ご静聴ありがとうございました!