Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持类似nginx的一致性hash吗? #30

Closed
i18nsite opened this issue Sep 3, 2024 · 9 comments
Closed

支持类似nginx的一致性hash吗? #30

i18nsite opened this issue Sep 3, 2024 · 9 comments
Labels
question Further information is requested stale

Comments

@i18nsite
Copy link

i18nsite commented Sep 3, 2024

https://blog.csdn.net/zhangskd/article/details/50256111
Nginx的负载均衡 - 一致性哈希 (Consistent Hash)

用法类似

location ~ ^/tran/([\w-]+) {
access_log /var/log/nginx/s.i18n.site_tran.access.log global_main;
error_log /var/log/nginx/s.i18n.site_tran.err.log error;
set $c $1;
proxy_pass http://i18n-c;
client_max_body_size 128m;
proxy_read_timeout      5m;
proxy_send_timeout      5m;
proxy_connect_timeout     60s;
}

upstream i18n-c {
  hash $c consistent;
  include upstream/_i18n.conf;
}
@vicanso
Copy link
Owner

vicanso commented Sep 3, 2024

可以参考一下文档:http://pingap.io/pingap-zh/docs/upstream/#algo%E7%9A%84hash
支持完整的path,但未支持具体到path的特定一部分

@vicanso vicanso added the question Further information is requested label Sep 3, 2024
@i18nsite
Copy link
Author

i18nsite commented Sep 4, 2024

现在这个hash是一致性hash吗?类似
https://blog.csdn.net/zhangskd/article/details/50256111
Nginx的负载均衡 - 一致性哈希 (Consistent Hash)

@vicanso
Copy link
Owner

vicanso commented Sep 4, 2024

是的,pingora有实现相关算法的模块,pingora-ketama

@i18nsite
Copy link
Author

i18nsite commented Sep 5, 2024

明白,再咨询一下,现在支持反向代理websocket吗, 如果有websocket的一直连着那么热重启还能生效吗?

@vicanso
Copy link
Owner

vicanso commented Sep 5, 2024

支持websocket的,热重启并不会中断连接中的请求,而且pingap已经支持大部分的配置均是热更新,不需要启动新的实例。

@i18nsite
Copy link
Author

i18nsite commented Sep 6, 2024

明白,
还有几个问题

  1. 是否有对http3的支持

另外如果支持http3,是不是能只当请求为http2的时候才添加头 add_header Alt-Svc 'h3=":443";ma=99999;persist=1';

  1. 是否可以对响应进行 zstd压缩的支持(如果响应已经压缩就不再压缩)

CleanShot 2024-09-06 at 11 39 05

这里实现上有个小坑:参见 tower-rs/tower-http#490

  1. 是否可以配置简单的http auth

  2. 证书是否可以配置默认申请泛域名证书,然后子域名和主域名复用这个证书吗?

  3. 是否支持类似nginx 的 OCSP Stapling
    https://www.sofineday.com/nginx-https-ocsp.html

  4. upstream支持ipv6吗

  5. 怎么添加/删除响应头?(能不能是不重复添加,如果原始返回已经包含了此头,就不添加)

nginx响应头还支持变量

add_header "Access-Control-Allow-Origin"  $http_origin always;
  1. url重写到本地静态文件怎么配置?类似nginx的Rewrite

  2. upstream怎么配置重试次数;另外,比如如果后端出错,可以自动屏蔽1分钟吗(除非所有节点都被屏蔽)?nginx可以配置这样的

  3. 有基于文件,可以配置容量上限的Cache 插件吗?

  4. Cache怎么清理缓存,比如nginx我可以这么配置清理缓存

set $token "abced";

proxy_cache_key "$uri";
proxy_hide_header "cache-control";
set $bypass 0;
if ($http_t = $token) {
  set $bypass 1;
}
proxy_cache_bypass $bypass;

最后,能不搞一个类似roadmap的开发蓝图

@vicanso
Copy link
Owner

vicanso commented Sep 6, 2024

Pingap是基于pingora开发的,所以基础能力受限于pingora的支持。

  1. Pingora有计划支持,但未有明确时间
  2. 已支持gzip、br以及zstd三种压缩方式(不过当前会与缓存有所冲突(ResponseCompression and cache cannot be used together cloudflare/pingora#283)
  3. 可以使用插件:http://pingap.io/pingap-zh/docs/plugin#basicauth
  4. 证书使用http-01 challenge 的形式,未支持泛域名,但可一次配置多个域名
  5. ocsp未支持
  6. upstream支持ipv4与ipv6,也可配置为仅使用ipv4
  7. 响应头的处理也可使用插件,支持添加或设置(未支持如果存在则不添加):http://pingap.io/pingap-zh/docs/plugin#responseheaders
  8. 静态文件也可使用插件:http://pingap.io/pingap-zh/docs/plugin#directory
  9. upstream配置health check即可,未支持自动屏蔽时长,仅是在检测失败则不可用,成功则可用:http://pingap.io/pingap-zh/docs/upstream#%E8%8A%82%E7%82%B9%E5%81%A5%E5%BA%B7%E6%A3%80%E6%B5%8B
  10. 缓存可以配置为基于内存或文件的形式(应用全局共享),配置之后使用插件即可:http://pingap.io/pingap-zh/docs/plugin#cache
  11. 由于内存缓存tinyufo暂未支持缓存清除,因此未提供接口的形式处理,暂时建议使用短缓存的形式

由于pingap暂时还只是我业余时间开发的项目,现在还未正式1.0版本,后续正式版本之后会添加对应的roadmap

Copy link

This question has been stale for a week. It will be closed in an additional day if not updated.

@github-actions github-actions bot added the stale label Sep 14, 2024
Copy link

This issue has been closed because it has been stalled with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested stale
Projects
None yet
Development

No branches or pull requests

2 participants