我需要创建一个服务器场,可以处理500多万个连接,500多万个主题(每个客户端一个),处理300k消息/秒.
我试图了解各种消息代理的功能,因此我目前正在使用两个RHEL EC2实例(r3.4xlarge)来创建大量可用资源.所以你不需要查找它,它有16vCPU,122GB RAM.我没有接近使用限制.
我无法通过600k连接限制.因为在客户端和服务器上似乎没有任何O/S限制(大量的RAM/CPU /等)限制了我?
我编辑了/etc/security/limits.conf如下:
* soft nofile 20000000
* hard nofile 20000000
* soft nproc 20000000
* hard nproc 20000000
root soft nofile 20000000
root hard nofile 20000000
Run Code Online (Sandbox Code Playgroud)
我编辑了/etc/sysctl.conf如下:
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 5242880 5242880 5242880
net.ipv4.tcp_tw_recycle = 1
fs.file-max = 20000000
fs.nr_open = 20000000
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_max_syn_backlog = 10000
net.ipv4.tcp_synack_retries = 3
net.core.somaxconn=65536
net.core.netdev_max_backlog=100000
net.core.optmem_max = 20480000
Run Code Online (Sandbox Code Playgroud)
对于Apollo:导出APOLLO_ULIMIT = 20000000
对于ActiveMQ:
ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS -Dorg.apache.activemq.UseDedicatedTaskRunner=false"
ACTIVEMQ_OPTS_MEMORY="-Xms50G -Xmx115G"
Run Code Online (Sandbox Code Playgroud)
我在客户端为eth0创建了20个额外的私有地址,然后分配它们:ip addr add 11.22.33.44/24 dev …
我对如何构建我的 React/GraphQL (Apollo) 应用程序感到有点困惑,因为在用户验证/登录之前不应建立连接。
目前我有这个:
class App extends Component {
render() {
return (
<ApolloProvider client={client}>
<Provider store={store}>
<Router>
<div>
<ul>
<li><Link to="/">Home</Link></li>
<li><Link to="/login">Log In</Link></li>
<li><Link to="/signup">Sign Up</Link></li>
</ul>
<AuthenticatedRoute exact path="/" component={HomePage} />
<Route path="/login" component={LoginPage} />
<Route path="/signup" component={SignupPage} />
</div>
</Router>
</Provider>
</ApolloProvider>
);
}
}
Run Code Online (Sandbox Code Playgroud)
这是网络接口的创建:
const networkInterface = createNetworkInterface({
uri: process.env.NODE_ENV === 'development'
? 'http://localhost:3000/graphql'
: 'TBD',
});
networkInterface.use([
{
applyMiddleware(req, next) {
if (!req.options.headers) {
req.options.headers = {}; // Create the header object …Run Code Online (Sandbox Code Playgroud) (这是对https://github.com/apollographql/apollo-client/issues/1886的跟进)
我正在尝试构建一个文本输入,它将在用户输入时更新值.
我首先尝试使用optimisticResponse更新本地缓存作为用户类型.这是有效的,除了它会在每次击键时触发突变.除了通过请求充斥网络之外,还存在网络不一致的问题.最后一个突变可能首先到达,第一个突变最后到达.这导致服务器以过时值结束.以下是此竞争条件的示例:
type: a
mutate request: a
type: b
mutate request: ab
arrives on server: ab
arrives on server: a
Run Code Online (Sandbox Code Playgroud)
现在服务器在graphql中记录了"a",这是不正确的.
为了缓解这个问题,我对按键事件进行了辩论.虽然这确实有助于上述竞争条件,但它并没有解决它.如果网络比你的去抖阈值慢,那么仍有可能出现竞争条件.
因为我们现在正在对文本输入进行去抖动,所以我们需要向该React组件引入一个本地状态,以便在用户输入时立即更新(如github问题中建议的@jbaxleyiii).现在我们的状态位于两个位置(组件状态和apollo缓存).
这个问题的一个大问题是组件在收到新道具时不会更新.例如.当graphql更新并推送到客户端时.
因为debounce实际上并没有解决竞争条件,所以我添加了一个网络队列(除了去抖动),它将管理变异请求,以确保一次只有一个变异.如果在飞行中有一个突变请求时它会收到突变请求,它会将它排队等待第一个返回时被触发.如果已经有一个排队的突变,它将丢弃它并将其替换为新的突变(一次只能有一个项目在队列中).这是一个例子:
type: a
send mutate request: a
type: b
queues mutate request: ab << wait to send this until "a" comes back
type: c
replaces queued request: abc << discard the queued request for "ab", it's old now
response from server: a
send mutate request: abc …Run Code Online (Sandbox Code Playgroud) 是否有适用于C++(Windows和Linux)和.NET的GraphQL客户端库?
从Apollo网站我只能看到React,Vue.js,Angular,Android,iOS,Ember和Meteor的客户.
如果有一个用于C++和.NET的Apollo客户端,它位于何处?
如果没有,应该使用什么?
我正在使用apollo-server和apollo-graphql-tools,我有以下架构
type TotalVehicleResponse {
totalCars: Int
totalTrucks: Int
}
type RootQuery {
getTotalVehicals(color: String): TotalVehicleResponse
}
schema {
query: RootQuery
}
Run Code Online (Sandbox Code Playgroud)
和解析器功能是这样的
{
RootQuery: {
getTotalVehicals: async (root, args, context) => {
// args = {color: 'something'}
return {};
},
TotalVehicleResponse: {
totalCars: async (root, args, conext) => {
// args is empty({}) here
.........
.........
},
totalTrucks: async (root, args, conext) => {
// args is empty({}) here
.........
.........
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是如何在任何子args解析器中访问root解析器(getTotalVehicals)中可用的?
我正在使用apollo 2.0。我首先authUser graphql调用服务器以提供给定的用户名和密码,这会生成jwt令牌并作为响应返回令牌。我确实看到成功登录后将User其存储cache为id键值。我有Buy按钮,我需要做validateSSOSession的给予token。对于validateSSOSession,我需要token从缓存中读取。
我经历了client.readQuery,client.fragementQuery但是两者都不适用于我的情况bcz client.readQuery期望在服务器之前调用过相同的查询,并且我应该具有相同的变量。由于我没有,username/password所以我不能打电话client.readQuery。同样,client.fragementQuery期望id是强制性的。由于我没有,id因此无法使用它。
暂时,我只是data从下面cache进行迭代和过滤User。
const data = client.cache.data.data;
const users = _.values(data).filter(obj=>(obj.__typename==='User' && obj.token));
const token = users[0].token;
// Make graphql call to validate sso
const { data } = await client.query({
query: GET_SSO_USER,
variables: { token …Run Code Online (Sandbox Code Playgroud) 只是一个基本的apollo查询请求
this.client.query({
query: gql`
{
User(okta: $okta){
id
}
}`
}).then(result => {
this.setState({userid: result.data.User});
console.log(this.state.userid.id)
}).catch(error => {
this.setState({error: <Alert color="danger">Error</Alert>});
});
Run Code Online (Sandbox Code Playgroud)
问题是,如何/在何处设置$ okta变量.
没有在Stackoverflow或Google上找到解决方案 - 如果有人可以帮助我会很棒:)
所以我有这两个模式
Schema1
type Permission {
relation: Relation
}
enum Relation {
ONE
TWO
THREE
}
Run Code Online (Sandbox Code Playgroud)
SCHEMA2
type Permission {
relation: Relation
}
enum Relation {
FOUR
FIVE
SIX
}
Run Code Online (Sandbox Code Playgroud)
预期结果类似于:(但我对不同的想法持开放态度)合并后我想做的查询是:
{
permissions{
relation
}
}
Run Code Online (Sandbox Code Playgroud)
得到一个结果
"permissions": [
{
"relation": "ONE"
},
{
"relation": "SIX"
}
]
Run Code Online (Sandbox Code Playgroud)
要么
"permissions": [
{
"relation": "schema1ONE"
},
{
"relation": "schema2SIX"
}
]
Run Code Online (Sandbox Code Playgroud)
和突变像:
mutation{
createPermission(
relation: ONE
){
relation
}
}
mutation{
createPermission(
relation: SIX
){
relation
}
}
Run Code Online (Sandbox Code Playgroud)
要么
mutation{
createPermission(
relation: …Run Code Online (Sandbox Code Playgroud) 我正在一个项目中使用Django作为后端,Vue作为前端,并尝试实现Apollo / Graphene / GraphQL作为数据传输层。大多数功能都可以使用,但是我对CORS / CSRF设置一无所知。
有谁知道如何通过CSRF令牌解决对graphql / graphene API的保护?在django日志终端上,我得到:
Forbidden (CSRF token missing or incorrect.): /graphql/
Run Code Online (Sandbox Code Playgroud)
...在Vue / Js控制台上,我看到了
Cross-Origin Request Blocked: The Same Origin Policy disallows
reading the remote resource at http://localhost:8080/sockjs-node/
info?t=1558447812102.
Run Code Online (Sandbox Code Playgroud)
您可以在此处查看(并结帐,它是开源的)此项目。
http:// localhost:8000,http:// localhost:8000 / admin和http:// localhost:8000 /都可以正常工作。该查询query{menuItems{id, title, slug, disabled}}在graphiql中运行良好。
settings.py:
Forbidden (CSRF token missing or incorrect.): /graphql/
Run Code Online (Sandbox Code Playgroud)
问题在这里:* yarn serve在http:// localhost:8080./manage.py …
我在我的 Apollo Client 代码中随机得到了这个。我正在使用使用 isMounted 标志包围所有 setState 的反模式,以防止在卸载组件或用户离开页面时尝试设置状态。但我仍然得到这个
Store reset while query was in flight (not completed in link chain)
Run Code Online (Sandbox Code Playgroud)
是什么赋予了?
apollo ×10
graphql ×7
react-apollo ×5
reactjs ×2
apollostack ×1
cors ×1
csrf ×1
django ×1
graphql-js ×1
hivemq ×1
mqtt ×1
tcp-ip ×1
typescript ×1
vue.js ×1