联合GraphQL的方法

图片来自dgraph.io
图片来自dgraph.io

程序员喜欢一些好故事,所以我希望在生产环境中使用GraphQL进行复合API的五年历程(在100ms延迟下每秒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 .

:

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 .

  • (- )

, , .. .

网络应用加载时的网络请求
-

:

工作的服务

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 _, .

一个联邦Pipedrive数据图(左侧),其中包含2个服务(539个中的一个)和一个尚未联合的线索服务图(右侧)
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?

对于外部世界,我希望Apollo与其Constellation项目一起加快对Rust的请求处理,以使这10%的性能税不存在,并且能够在不对其进行重大更改的情况下联合graphql服务。

总的来说,这是一个享受很多复杂事物的绝佳时机!




All Articles