フェデレーションGraphQLへの道

dgraph.ioからの画像
dgraph.ioからの画像

プログラマーは良い話が大好きなので、実稼働環境でGraphQLを使用する複合APIへの5年間の旅(100ミリ秒の遅延で毎秒110リクエストのピーク)が興味深いものになることを願っています。

[お急ぎの場合は、以下のレッスンに進んで、オープンソースのgraphql-schema-registryをご覧ください]

サンプルテストスキーマを含むスキーマレジストリ
サンプルテストスキーマを含むスキーマレジストリ

仕事

, Pipedrive ( 2020 10 ), REST API . /users/self, , , 30 . PHP , . , .

/ユーザー/残りのトラフィックの遅延の自己分散
/users/self

, .

, graphql.

3-4 , , , - - elixir graphql. MySQL Pipedrive /graphql.

, , - CRUD, .

2019, , GraphQL stitching graphql-compose REST API. , , - graphql .

:

  • . dataloader', N+1 . - .

  • . , , . - - , - .

2019, , Apollo , . , Core, .

, POST gateway .

graphql - . , Protobuf Thrift, GRPCOData.

, graphql (insights, teams) , ( User). typescript + relay , .

.

, - API ? ? Gateway - ? .

, - , - . Confluent’s schema-registry  Atlassian’s Braid, , Java, .

3 :

  • ( ) 15%. REST /graphql

  • 30%. graphql .

  • (- )

, , .. .

Webアプリのロード時のネットワークリクエスト
-

:

作業するサービス

schema-registry , , (swagger, typescript, graphql, avro, proto). .

Gateway schema-registry . frontend autocomplete .

, graphql , , .

/users/self - ? (!). - , .

( 2020), - 13% 25% (- ), UI Datadog.

, - REST.

- ( 600+ ), - . IOS- Android- graphql .

60 , -

? , .

Mark Stuart, Paypal Engineering

Apollo studio    . gateway.

作成したスキーマ検証ツールキット

, - , - . opensource - graphql-schema-registry.

- Pipedrive. , DC . , , , ?

graphql gateway . , gateway .

, gateway , - . Apollo studio - .

, Apollo , .. . .

, ( -) . . Gateway schema-registry /schema/compose , .

schema-registry ,

サービス開始時のスキームの登録

REST Graphql API, , REST.

REST

REST graphql, openapi-to-graphql, .

- , , ? REST .

, REST API , .

REST API . , - deal.pipeline_id. graphql, ,

json-. , REST _, .

2つのサービス(539のうち)を含むフェデレーションPipedriveデータグラフ(左)と、まだフェデレーションされていないリードサービスグラフ(右)
Pipedrive () 2 ( 539) -- leads ()

CQRS

Pipedrive TTL-.

, , . , . 3 .

- PHP-, nodejs ( monograph), memcached. -. , .

CQRS pattern. , 80% .

NewRelicに基づく米国地域のモノリス(左)とgraphqlゲートウェイ(右)の平均応答待ち時間
() graphql gateway () US NewRelic

- . , - . - , identity. .

Identity , kafka, monograph . , ( 1 ), . , - .

APM - . Datadog .

, 30 memcached. . memcached 10, , 220. , - mcrouter. , 20 .

- , getMulti . resolver' , 5 debounce .

. graphql gateway . , .

28 30 , 500, .

graphql , /graphql . 3-5 , ( debounce FE )

, - (APM) tracing:true, .

700 300 . , ( performance.now()), .

graphql gateway  Chrome DevTools, , .

  .

, graphql . /graphql ( vendors.js) . , - - .

- graphql    gql . bundle, fetch. , - - . server-side-rendering service workers .

ラップ/ graphqlクエリが残っています
/graphql

graphql , . , , rate limit .

graphql-cost-analysis , , - , , ( , , CPU, ). gateway schema-registry. .

js/typescript . graphql .

koa-graphql  apollo-server-koa GraphQLSchema . apollo/server :

buildFederatedSchema([{typeDefs, resolvers}])

, , gql , schema.graphql , ,  ASTNode ( parse / buildASTSchema)

canary

- .

, graphql 100 -"". 1000 , 1%, 10%, 30%, 50% .

company ID . , - , graphql . - graphql .

, , ( ), .

- graphql , - , , . - .

graphql API , API. OAuth ( ) .

schema-registry , gateway - , , , (persisted query), .

, go, - GRPC - , graphql , gateway. GRPC - , graphql msgpack?

外の世界については、ConstellationプロジェクトのApolloが、Rustのリクエストの処理をスピードアップして、この10%のパフォーマンス税が存在せず、後者に大きな変更を加えることなくgraphqlサービスを統合できるようになることを願っています。

一般的に、複雑さが多い開発を楽しむ絶好の機会です!




All Articles