Git Product home page Git Product logo

spider's Introduction

DHT网络爬虫

Build Status

高性能DHT网络爬虫,5美金的单核,768MB的VPS上,每秒处理UDP请求超过12K,内存占用不超过100MB,每天抓取数千万去重infohash

主要特点

  • 内存复用
  • map去重
  • id 均匀分散
  • 动态调整find_node速率
  • 限速

示例

参考example

安装

go get github.com/btlike/spider

参考项目

流量图

附一张流量图

常见问题

终于运行起了爬虫,但运行没几分钟,各种linux问题出现了,最开始应该是ulimit问题,这个问题很好解决,参考这个文章。然后会出现开始大量报出:nf_conntrack: table full, dropping packet。这个问题参考这个文章。原因就是,

nf_conntrack/ip_conntrack 跟 nat 有关,用来跟踪连接条目,它会使用一个哈希表来记录 established 的记录。nf_conntrack 在 2.6.15 被引入,而 ip_conntrack 在 2.6.22 被移除,如果该哈希表满了,就会出现:nf_conntrack: table full, dropping packet。

解决办法很简单,我们让某些端口的流量不要被记录即可。假如我们运行100个节点,而节点监听的端口是20000到20099,我们只需要执行以下命令即可。

iptables -A INPUT -m state --state UNTRACKED -j ACCEPT
iptables -t raw -A PREROUTING -p udp -m udp --dport 20000 -j NOTRACK
...... //从端口20000一直到20099,每个端口一行
iptables -t raw -A PREROUTING -p udp -m udp --dport 20099 -j NOTRACK

spider's People

Contributors

btfak avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.