sinmetal / til

Today I Learned
MIT License
0 stars 0 forks source link

次のアーキテクチャどうするかなー #9

Open sinmetal opened 3 years ago

sinmetal commented 3 years ago

Server

Static Contents

Serverless NEG

Domain sinmetalcraft.jp

OGP などをちょびっと変更する必要があるので、動的だが、CDNに乗せれる構成がよい。 後ろはApp Engine or Cloud Runでいい感じに動いてくれそうな方を採用する感じだろうか? Spin-upとかはApp Engineが強そうだが、CI/CDを分離しやすく、Deployが早いのはCloud Runな気がする。 CDNにCacheする時間次第なところだが、料金的にはどちらも無料枠に収められるか?

fastlyもいいかな?と思ったけど、月額最低料金が$50なので、ひとまず選択肢から外した

Auth

Firestore Native ModeをClientから使いたいので、Firebase Authが無難そう

Normal API

さくっと動く普通のAPIたち Domain api.sinmetalcraft.jp?

API Gateway

API Gateway 使ってみようかな?と思ったけど、なんかまだ使いやすそうな感じじゃなかった。 config側をFirstで作るから、それを作る仕組みが必要。 Custom Domain 割り当てることができない。

Auth Firebase いける! https://cloud.google.com/api-gateway/docs/authenticating-users-firebase https://github.com/sinmetal/til/issues/9#issuecomment-711127478

OpenAPIの仕様から離れたものを同じドメインでPathベースで動かすのかとは無理そう HTTP LBと接続できるようになれば・・・?

来年とかにはよくなってくるのかなー?

Serverless NEG

API Gateway 使わないとすると、普通にServerless NEG使うか? この場合、URLはsinmetalcraft.jp/api とかだろうか

Large Power API

通常のAPIと違い、検索を行うなど、大きめなInstanceが必要な処理を行うユースケース

GKE上に配備し、Internal LBを介して、APIレイヤーからアクセスする。 Internal LB for GKE

Cloud Tasks & Cloud Pub/Sub

Serverless NEGにIAPを書けて、やっていくか? APIというか、Handlerをぶっ叩くだけだから、直接 Cloud Run or App Engineに突き刺してもいい気はするが・・・ https://cloud.google.com/iap/docs/enabling-compute-howto

Local Dev

dev 環境にLocalからアクセスしたい

Firebase Authなら、Localから普通に突破できる気がする

sinmetal commented 3 years ago

Network

GKEが存在するProjectにShared VPCを作って、そこに全員ぶら下がるとかな

sinmetal commented 3 years ago

Resource Management

Config Connector 使ってみようかなー。 実際、動くのか試しみないと、決断しづらいが、既存のResouceのImportとか、ぼちぼちきれいにできそうな気がする

クラスター作り直しの時に、クラスターが二重に存在するのはどうなるのかな? 新クラスターの方にいったんyamlぶっこまなきゃ、とりあえずいい気はするが

sinmetal commented 3 years ago

Serverless NEG Limit

現状のLimitでかなり気になるもの https://cloud.google.com/load-balancing/docs/negs/serverless-neg-concepts?hl=en#limitations

Deadline

baseend-serviceのdeadlineを30secから変更できないので、Cloud Tasksなどの非同期Requestを受け取って処理するのはつらそう。 Cloud Tasksたちは、直接App EngineやCloud Runに突き刺すべきか? ただ、そうすると、認証周りがややこしくなりそうである。 https://cloud.google.com/load-balancing/docs/backend-service#timeout-setting

You cannot modify the default 30-second backend service timeout of a serverless NEG backend service. Attempting to modify the backend service configuration to increase the timeout (by setting the resource.timeoutSec property) results in the following error: Timeout sec is not supported for a backend service with Serverless network endpoint groups.
sinmetal commented 3 years ago

Serverless NEG Price

最低料金は fowarding rule 1個で 月額3000円ぐらい

https://cloud.google.com/compute/network-pricing?hl=ja#lb

sinmetal commented 3 years ago

Internal HTTP LB

月額 5400円ぐらい

proxy instance が zoneごとに1つ立つので、月額の計算は以下 $0.025 3 24 * 30

https://cloud.google.com/compute/network-pricing?hl=ja#internal-https-lb

Internal HTTP LB地味に最低料金が高いので、Client Side LBでなんとかしたい気になるな・・・ GKE使う場合はNodeport https://cloud.google.com/kubernetes-engine/docs/concepts/service?hl=ja#service_of_type_nodeport 1個作って、そこにGatewayみたいなの置いて、そいつに中のserviceにアクセスしてもらったりするか? まぁ、全部 node port で公開してもいいかもしれないが、どんなservice動かすかで考えよう

sinmetal commented 3 years ago

Custom Domain 利用時のレイテンシ問題

Cloud Run も asia-northeast1 だとレイテンシが高いので、Serverless NEGが推奨されてた https://cloud.google.com/run/docs/issues?hl=ja#latency-domains

sinmetal commented 3 years ago

Backend BucketはIAPをサポートしていない

IAPをONにしてても、Backend Bucketにはかからないって感じならいいが、全体がエラーになるなら、つらいな https://cloud.google.com/load-balancing/docs/https/ext-load-balancer-backend-buckets#limitations

sinmetal commented 3 years ago

Firebase AuthのID Tokenの発行

https://firebase.google.com/docs/auth/admin/verify-id-tokens?hl=ja#web