Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.


EDM 並不是只有寫程式呼叫 API 就結束了。為了將最重要的信件「送達率」提高,需要有好的 Email Reputation。而好的 Reputation 又取決於 1) Authentication 2)Bounce management 3)List cleanliness 4)User engagement (recipient feedback) 等重要的概念

了解了 EDM 的領識知識後介紹如何在 Google Cloud Platform 上搭建彈性並可巨量送信的架構

最後介紹如何搭配 CI/CD 與 GCP 上 Google Cloud Source Repositories 及 Stackdriver Debugger 整合應用


  1. 1. 60分鐘完送百萬EDM,背後 雲端CI/CD實戰大公開
  2. 2. HELLO! I am Cage Chung I am here because I like to share my experiences. You can find me at / QNAP 雲端應用部資深工程師
  3. 3. [您知道”GCPUG”要怎麼唸嗎?為什麼會有一隻狗在 Logo裡面呢?] Google Cloud Platform User Group的縮寫是GCPUG GCPUG直接唸成G.C.P.U.G?當然可以! 但它也可以分開來,唸成 G.C. PUG喔~ Pug,指的是巴哥犬,所以 GCPUG的Logo中間才會有一隻可愛的巴哥犬喲。 下次聽到別人說G.C. PUG 的時候,您就可以大聲 說:「我也是G.C. PUG社團成員!」
  4. 4. 17th Meetup
  5. 5. 大綱 ◉ EDM 二三事 & 送信服務架構 ◉ CI (持續整合) & CD (持續部署) 整合 ◉ Demo/Cloud Source Repositories, Stackdriver Debugger ◉ 小提示 & 學習資源
  6. 6. EDM 二三事 & 送信服務架構 Let’s start with the first set of slides 1
  7. 7. 寄送 Email 好簡單 - API Call # Google App Engine Send Email example (Python) from google.appengine.api import app_identity from google.appengine.api import mail def send_approved_mail(sender_address): # [START send_mail] mail.send_mail(sender=sender_address, to="Albert Johnson <>", subject="Your account has been approved", body="""Dear Albert: Your account has been approved. You can now visit and sign in using your Google Account to access new features. Please let us know if you have any questions. The Team """) # [END send_mail] send_approved_mail('{}'.format(app_identity.get_application_id()))
  8. 8. 客戶最關心的事 - 送達率 Sender (Bob) Recipients (Alice / Sunrain)
  9. 9. Email Reputation Sender Score Average Delivered 0-60 21% 61-70 67% 71-80 68% 81-90 92% 91-100 95% [Your Email Reputation]( [5 Ways to Check Your Sending Reputation | SendGrid]( ◉ Authentication ◉ Bounce management ◉ List cleanliness ◉ User engagement (recipient feedback)
  10. 10. EDM 實際會面臨到的種種問題... Email Reputation Spamminess WhiteList Shared IP DK(IM)/SPF Blocks Invalid Emails Blacklists SpamDedicated IP Scores
  11. 11. [Best Practices in Email Deliverability - Act-On Software](
  12. 12. [垃圾邮件检测结果]( Mail Tester
  13. 13. Sendgrid 如何幫我們送信 [Email Message Flow Explained - SendGrid | SendGrid](
  14. 14. Sendgrid 遊戲規則 [IP Warmup Schedule - SendGrid Documentation | SendGrid](
  15. 15. [SendGrid | Heroku Dev Center](
  16. 16. 送信服務架構
  17. 17. 我們所使用到的資源 AppEngine BigQuery CloudStorage DataStore CloudEndpoints Sendgrid A fast, economical and fully managed data warehouse for large-scale data analytics BigQuery Cloud Datastore is a highly- scalable NoSQL database for your web and mobile applications. DataStore A powerful platform to build web and mobile apps that scale automatically. App Engine A Powerful, Simple and Cost Effective Object Storage Service. Cloud Storage Delivering your transactional and marketing email through one reliable platform. Sendgrid Create RESTful APIs on App Engine accessible to iOS, Android and Javascript clients. Cloud Endpoints
  18. 18. AppEngine BigQuery CloudStorage DataStore CloudEndpoints Sendgrid UI 彈性化擴展層、排程器、 Tasks 處理。針對不同任務的機器予給優 化的資源,並可自動進行擴展 EDM Server
  19. 19. AppEngine BigQuery CloudStorage DataStore CloudEndpoints Sendgrid Cloud logging / sendgrid webooks (tracking - bounce, click, open, spam) 的資料值串接 BigQuery, 作 後序分析 資料分析
  20. 20. AppEngine BigQuery CloudStorage DataStore CloudEndpoints Sendgrid 檔案暫存 EDM html 檔案、連絡人清單暫存區
  21. 21. AppEngine BigQuery CloudStorage DataStore CloudEndpoints Sendgrid RESTful API endpoint 提供 RESTful API 給前端應用程式
  22. 22. https://<gcp-project-id> http://localhost:8080/_ah/api/explorer
  23. 23. AppEngine BigQuery CloudStorage DataStore CloudEndpoints Sendgrid Sendgrid 送信服務商,提供豐富的報表、 EDM 相關的 know how,亦有 webhook 可以串接
  24. 24. AppEngine BigQuery CloudStorage DataStore CloudEndpoints Sendgrid Metadata 儲存 Nosql datastore. 儲存 EDM 送信服 務過程中相關 Metadata. 連絡人清 單、Log 等
  25. 25. 架構 queue MetadataEDM Server App Engine Task Queues Cloud Storage endpoints API (OAuth 2) Cloude Datastore CSV uploadrecipients Store/retrieve metadata RESTful APIs for recipients m ail send cron ...
  26. 26. # dispatch.yaml application: your-project-id dispatch: - url: "*/favicon.ico" module: default - url: "" module: default - url: "*/tasks/*" module: tasks - url: "*/googleae8f4bcce8bec00c.html" module: ownership - url: "*/*" module: "default" # default/app.yaml automatic_scaling: min_idle_instances: 1 # tasks/app.yaml instance_class: F4 automatic_scaling: min_idle_instances: 2 min_pending_latency: 30ms max_pending_latency: 300ms # max_concurrent_requests: 80 # max_idle_instances: automatica # default value # min_pending_latency: 30ms # default value # max_pending_latency: automatic # max_concurrent_requests: 50
  27. 27. EDM Server EDM 檔案 聯絡人清單 Queue API Retry fail Retry cron Schedule cron Success Log 流程示意圖 failLog
  28. 28. CI(持續整合) & CD (持續部署) 整合 Let’s start with the second set of slides 2
  29. 29. Image by[每个架构师都应该研究下康威定律](
  30. 30. Devops: CI & CD (Docker, gitlab, GCP) Bitbucket Github Jenkins Travis CI CircleCI Docker Gitlab Cloud Source Repositories Stackdriver Debugger
  31. 31. Origin imgae from and modified [DevOps:持續整合&持續交付(Docker、CircleCI、AWS)]( docker-circleci-aws-beanstalk.html)
  32. 32. 簡單腳本 ◉ Local Development / Test ◉ Gitlab-ci-multi-runner ◉ Local runner exec test - docker ◉ Gitlab runner test docker ◉ gcloud deploy ◉ Google App Engine ◉ Google Cloud Source Repositories ◉ Stackdriver Debugger
  33. 33. Gitlab Project Runner
  34. 34. Gitlab Project Variables
  35. 35. Register Gitlab runner $ gitlab-ci-multi-runner register WARNING: Running in user-mode. WARNING: The user-mode requires you to manually start builds processing: WARNING: $ gitlab-runner run WARNING: Use sudo for system-mode: WARNING: $ sudo gitlab-runner... Please enter the gitlab-ci coordinator URL (e.g. Please enter the gitlab-ci token for this runner: <your-gitlab-project-runner-register-token> Please enter the gitlab-ci description for this runner: [Kai-Chus-MBP]: edm Please enter the gitlab-ci tags for this runner (comma separated): gae,python,edm Registering runner... succeeded runner=kvwzB1cE Please enter the executor: ssh, shell, parallels, docker, docker-ssh, virtualbox: docker Please enter the default Docker image (eg. ruby:2.1): cage1016/gitlab-ci-gcp:v1.6 Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
  36. 36. .gitlab-ci.yaml image: cage1016/gitlab-ci-gcp:v1.6 before_script: - export CLOUDSDK_CORE_DISABLE_PROMPTS=1 - export CLOUDSDK_PYTHON_SITEPACKAGES=1 - export GCP_PROJECT=cage-20160705-edm - export GCP_PROJECT_VERSION=uat types: - test - deploy test: stage: test script: - sh ./scripts/ deploy: stage: deploy script: - sh ./scripts/ only: - develop
  37. 37. .gitlab-ci.yaml (./scripts/ #!/usr/bin/env bash virtualenv env source env/bin/activate # install Google App engine test env packages from requirements.testing.txt pip install -r requirements.testing.txt echo $GCLOUD_SERVICE_JSON_KEY > tasks/cage-20160705-edm-cc07ec5bf115.json # run tests py.test tasks/tests
  38. 38. .gitlab-ci.yaml (./scripts/ #!/usr/bin/env bash echo $GCLOUD_KEY > key.json gcloud auth activate-service-account $GCLOUD_ACCOUNT --key-file key.json gcloud --quiet config set project $GCP_PROJECT # tasks module pip install -r tasks/requirements.txt -t tasks/lib/ gcloud --quiet preview app deploy tasks/app.yaml --no-promote --version $GCP_PROJECT_VERSION --project $GCP_PROJECT # gen-repo-info-file gcloud app gen-repo-info-file git push google develop
  39. 39. Local runner exec test docker // [install gitlab-ci-multi-runner]( // list and register gitlab-ci-runner $ gitlab-ci-multi-runner list Listing configured runners ConfigFile=/Users/cage/.gitlab-runner/config.toml edm Executor=docker Token=<your-token> URL= // prepare a docker-machine for gitlab-ci-multi-runner $ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS runner - virtualbox Running tcp:// v1.11.0 // run a gitlab-ci-multi-runner test via docker $ gitlab-ci-multi-runner --debug exec docker test --env "GCLOUD_KEY=$GCLOUD_KEY" --env " GCLOUD_ACCOUNT= $GCLOUD_ACCOUNT" --env="GCP_PROJECT_VERSION=$GCP_PROJECT_VERSION"
  40. 40. $ git remote add google[PROJECT_ID]/r/default // generates a file named source-context.json, which contains information about the version of the source code used to build the application $ gcloud preview app gen-repo-info-file // push code to google cloud source repositories $ git push google master Google Cloud Source Repositories - List
  41. 41. Google Cloud Source Repositories - Source Code
  42. 42. Stackdriver Debugger | Source Code
  43. 43. Stackdriver Debugger | Debug
  44. 44. Image by [每个架构师都应该研究下康威定律](
  45. 45. Demo/Cloud Source Repositories, Stackdriver Debugger Let’s start with the third set of slides 3
  46. 46. 小提示 & 學習資源 Let’s start with the fourth set of slides 4
  47. 47. “5G Google cloud storage for App engine for FREE <project-id> staging.<project-id>
  48. 48. “App Engine Admin API Cloud Source Repositories API Google Cloud Storage
  49. 49. 學習資源 ◉ [Best Practices in Email Deliverability - Act-On Software](https: // ◉ [Getting Started - SendGrid Documentation | SendGrid](https: // ◉ [Newsletters spam test by](http://www.mail- ◉ [Your Email Reputation](http://www.slideshare. net/emaildelivered/email-reputation-2)
  50. 50. 學習資源 ◉ Deploying to App Engine or Managed VMs from Travis CI ◉ [Deploying to App Engine or Managed VMs from Travis CI - YouTube]( v=7U4jjRw_AJk& ◉ [GoogleCloudPlatform/continuous-deployment-demo](https: // demo)
  51. 51. 學習資源 ◉ GCP ◉ [Cloud Source Repositories - Private Git Repositories — Google Cloud Platform]( repositories/) ◉ [Stackdriver Debugger - Production Debugging - Google Cloud Platform — Google Cloud Platform]( com/debugger/) ◉ [Managed VMs lab ·](http://kaichu. io/2015/09/managed-vms-lab/)
  52. 52. DevOps (Development & Operations) Install the necessary apps with one-click on demand and the system will automatically finish the set-up process Quickly build a development environment ideally suited for collaboration One NAS with Multiple projects Recommended apps for quick installation : Private Registry, GitLab, and Jenkins.
  53. 53. THANKS! Any questions? You can find me at /