Upgrade to Pro — share decks privately, control downloads, hide ads and more …

スタートアップでよく作るこの機能、サーバーレスならこうやります / Serverless Start up

kensh
November 17, 2022

スタートアップでよく作るこの機能、サーバーレスならこうやります / Serverless Start up

スタートアップでは少ない人数で最大限の価値を生み出す工夫をどの企業でも考えていらっしゃると思います。
アイデアが浮かんだらそれが成功するか失敗するかは、頭の中で考えていても分かりません。
まずは作って市場で試してみることから始めるということをスタートアップの皆様は実行されているはずです。
そのアイデアを実現するために AWS のサーバーレスがどのようにお役に立てるかお話ししたいと思います。

kensh

November 17, 2022
Tweet

More Decks by kensh

Other Decks in Technology

Transcript

  1. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Kensuke Shimokawa / _kensh Snr. Serverless Specialist Amazon Web Services Japan G.K. スタートアップでよく作る この機能、サーバーレスなら こうやります AWS Startup Tech Meetup 福岡 Slides https://speakerdeck.com/_kensh/ Qiita https://qiita.com/_kensh
  2. Kensuke Shimokawa / _kensh Snr. Serverless Specialist Amazon Web Service

    Japan --- work: - サーバーレス技術 - 地域創⽣ Slides https://speakerdeck.com/_kensh/ Qiita https://qiita.com/_kensh 趣味︓図書館のヘビーユーザー
  3. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. ローカル x スタートアップ が サーバーレスを使うべき理由
  4. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. ローカル x スタートアップ がサーバーレスを使うべき理由 サーバーを管理している時間も労力もかけたくない ビジネスに集中したい 実験的な環境を手に入れたい
  5. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. サーバーレスどうやって始めていくの? https://aws.amazon.com/jp/events/aws-event-resource/hands-on/
  6. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. スタートアップでよく作る この機能、サーバーレスなら こうやります
  7. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. UX を改善したい場合
  8. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. API まわりで UX を悪くするケース Endpoint Endpoint 時間のか かる処理 アクセスが集中する バックエンド処理に時間がかかる
  9. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. アクセスが集中する Endpoint 処理 202 Accepted キュー リクエストは⼀旦 202 Accepted でレスポンスされ、キューに⼊った メッセージは⾮同期に処理される
  10. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. バックエンド処理に時間がかかる Endpoint 時間のか かる処理 キュー 202 Accepted 時間のかかる処理は、⼀旦キューイングされてキューからメッセージ を取得する別のサービスによって処理される
  11. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 結果をどのように受け取るか • ユーザーアクション • 画⾯遷移時に取得 • ボタンクリックなどのアクション • ポーリング • WebSocket
  12. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. バックエンド処理に時間がかかる Endpoint 時間のか かる処理 キュー WebSocket 処理が終われば、処理プロセスがWebSocketを介してクライアントに 結果通知を push する
  13. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. バックエンド処理に時間がかかる Endpoint 時間のか かる処理 キュー WebSocket Amazon API Gateway
  14. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. バックエンド処理に時間がかかる Endpoint 時間のか かる処理 キュー WebSocket Amazon API Gateway Amazon SQS
  15. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. バックエンド処理に時間がかかる Endpoint 時間のか かる処理 キュー WebSocket Amazon API Gateway AWS Lambda Amazon SQS AWS のサーバーレスサービスに当てはめると、Endpoint実装には API Gateway キューイングには SQS、そして処理には Lambdaが使える
  16. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 同期 API との共存 Endpoint 時間のか かる処理 キュー WebSocket Amazon API Gateway AWS Lambda Endpoint 処理 非同期 同期 Amazon SQS 同期処理と⾮同期処理は、どちらかだけ利⽤するという感じではなく 両⽅をアーキテクチャに組み込むことができる
  17. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. サクッとWebhookしたい場合
  18. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Webhook を投げる側 AWS Step Functions Express Workflow Amazon API Gateway HTTP Endpoint Lambda function Amazon SNS Amazon EventBridge Lambda function HTTP Endpoint ⾮同期 ⾮同期 ⾮同期 Subscription API Destination HTTP Integration import requests url = 'https://example.com/' response = requests.get(url) 同期 retry rate retry rate auth auth DLQ retry DLQ 外部 API 呼び出しを⾮同期的に扱えないか waiting… Round-trip latency
  19. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Amazon EventBridge 異なるチーム間の Push型での情報連携(イベント通知)を可能にするイベントバス AWS Cloud AWS Cloud AWS Cloud Amazon EventBridge
  20. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Webhook を投げる側 function Amazon EventBridge ⾮同期 API Destination SaaS や 別システムで公開して いる Webhook にメッセージを 送信する際に EventBridge API Destination が利⽤できる
  21. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Webhook を受ける側 functionURL SaaS や 別システムに設定する Webhook ⽤のAPI endpointが 必要な場合 AWS Lambda functionURL が利⽤できる
  22. Thank you © 2022, Amazon Web Services, Inc. or its

    affiliates. All rights reserved. Kensuke Shimokawa _kensh Slides https://speakerdeck.com/_kensh/ Qiita https://qiita.com/_kensh
  23. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Appendix
  24. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. #AWSBuilders FunctionURL blog https://itnext.io/using-aws-lambda-function-url-to-build-a-serverless-backend-for-slack-a292ef355a5d