python多线程网络爬虫_Python网络爬虫多线程和多处理

简而言之,我的网络爬虫有两个主要工作。收集器和爬虫程序,收集器将收集每个站点的所有url项并存储非重复的url。爬虫程序将从存储器中获取url,提取所需的数据并将其存储起来。在2 MachinesBot machine -> 8 core, Physical Linux OS (No VM on this machine)

Storage machine -> mySql with clustering (VM for clustering), 2 databases (url and data); url database on port 1 and data port 2

目的:对100个站点进行爬虫,以减少瓶颈情况First case: Collector *request(urllib) all sites , collect the url

items for each sites and * insert if it's non duplicated url to

Storage machine on port 1. Crawler *get the url from storage port 1 ,

*request site and extract needed data and *store it's back on port 2

这导致了请求网站和mySql连接的连接瓶颈Second case: Instead of inserting across the machine, Collector store

the url on my own mini database file system.There is no *read a huge

file(use os command technic) just *write (append) and *remove header

of the file.

这导致连接请求网站和I/O(读、写)瓶颈(可能是)

这两种情况也有CPU限制的原因收集和爬行100个网站

正如我听说的I/O边界使用多线程,CPU边界使用多处理

两者都怎么样?好斗的?有什么想法或建议吗?在

你可能感兴趣的:(python多线程网络爬虫)