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

Problem when the DNS query failed #10

Closed
URenko opened this issue Feb 5, 2019 · 8 comments
Closed

Problem when the DNS query failed #10

URenko opened this issue Feb 5, 2019 · 8 comments
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@URenko
Copy link
Owner

URenko commented Feb 5, 2019

When the DNS query failed, the program will be blocked, and the CPU usage is high.
5a51a8e is just a temporary solution to avoid DNS query failed. When you want to reappear it, you have to roll it back. And you can test www.tumblr.com as it need many DNS queries.

@URenko URenko added bug Something isn't working help wanted Extra attention is needed labels Feb 5, 2019
@SeaHOH
Copy link

SeaHOH commented Apr 22, 2019

  1. 收到 host 的第一个查询时,先预设一个值存入缓存。
  2. 后续的相同查询检测到预设值就等待,直至有结果返回。
  3. 查询失败,缓存一个失败结果,再向请求连接返回错误页面。
  4. 缓存应支持过期,查询失败后可以设置一个较短的过期时间,以便重新查询。

@URenko
Copy link
Owner Author

URenko commented Apr 26, 2019

感谢,但是感觉还是治标不治本

@SeaHOH
Copy link

SeaHOH commented Apr 26, 2019

如果你的目标是永不失败,这是不可能的,这个处理流程我也是大量摸索和学习后才理解的。

@URenko
Copy link
Owner Author

URenko commented Apr 26, 2019

这的确是一个很好的方案,但是我想知道CPU占用高的原因😂,感觉问题不在于此。

@SeaHOH
Copy link

SeaHOH commented Apr 26, 2019

重点在 CPU 占用,那么要检查一下协程是否处理好了,一般都是没处理好造成阻塞。

但你这里的问题好像就是我上面讲的流程处理不好造成的,如果没有那个 Lock 就会同时启动大量相同的查询,然后也就能理解 CPU 占用为啥会飙升。

但是那个 Lock 是不适合用在这里的,因为也会阻止所有其它域名的查询,人为造成延迟,影响使用体验。

Accesser/accesser.py

Lines 254 to 260 in 1a9a85d

def DNSLookup(name):
if name in DNScache:
return DNScache[name]
else:
res = DNSquery(name)
DNScache[name] = res
return res

@URenko
Copy link
Owner Author

URenko commented Apr 26, 2019

是的,那个Lock只能是临时解决方法。
但是我觉得大量的DNS查询只是诱因,因为即使在CPU占用飙升后较长时间停止访问,CPU占用依然不会下降。
协程的处理是重点要关注的,我也觉得问题是这里。
有时间的话再改流程看看。

@SeaHOH
Copy link

SeaHOH commented Apr 26, 2019

才注意你的代理并没有使用协程,这会导致性能问题。

但是我觉得大量的DNS查询只是诱因,因为即使在CPU占用飙升后较长时间停止访问,CPU占用依然不会下降。

这可能是 aioh2 的问题。

@URenko
Copy link
Owner Author

URenko commented May 7, 2019

考虑到aioh2更新较慢(pypi上的已无法在python3.7运行),doh-proxy亦不活跃,将考虑使用dnscrypt-proxy(支持DoH和dnscrypt协议)作为默认DNS解决方案。

由doh-proxy引起的bug一般情况下将不修复。

当前(v0.6.1)使用dnscrypt-proxy的方法:设置好dnscrypt-proxy后,在Accesser中配置DNS为一resolv.conf格式文件路径,内容为nameserver 127.0.0.1

当前dev分支使用dnscrypt-proxy的方法:把编译好的dnscrypt-proxy放在dnscrypt目录下就行。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants