跳至主要内容

Raspberry Pi从零开始搭建低成本NAS(7)-Aria2远程下载

原文地址是:http://www.mkitby.com/2016/01/15/raspberry-pi-nas-remote-download-aria2/
对作者表示感谢,作者关于NAS的系列文章写的都很棒,可以一看

远程下载内容比较多,所以分为两篇文章,先介绍Aria2,再介绍迅雷。
Aria2是一个轻量级命令行下载工具,支持HTTP/HTTPS, FTP, SFTP, BitTorrent and Metalink下载,但是不支持ed2k,支持JSON-RPC和XML-RPC调用,可以远程控制。
1.先安装aria2
sudo apt-get install aria2 –y
2.创建 aria2 配置文件 “/home/pi/.aria2/aria2.conf” 和 “/home/pi/.aria2/aria2.session” 这个文件 (我是以 pi 账户启动 aria2 的),
mkdir /home/pi/.aria2
touch /home/pi/.aria2/aria2.session
vim /home/pi/.aria2/aria2.conf
配置文件内容如下。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# 基本配置
# 下载目录
dir=/home/pi/nas-data/Inbox
# 下载从这个文件中找到的urls, 需自己建立这个文件
# touch /home/pi/.aria2/aria2.session
input-file=/home/pi/.aria2/aria2.session
# 最大同时下载任务数,默认 5
#max-concurrent-downloads=5
# 断点续传,只适用于 HTTP(S)/FTP
continue=true
# HTTP/FTP 配置
# 关闭连接如果下载速度等于或低于这个值,默认 0
#lowest-speed-limit=0
# 对于每个下载在同一个服务器上的连接数,默认 1
max-connection-per-server=5
# 每个文件最小分片大小,例如文件 20M,设置 size 为 10M, 则用2个连接下载,默认 20M
#min-split-size=10M
# 下载一个文件的连接数,默认 5
#split=5
# BT 特殊配置
# 启用本地节点查找,默认 false
bt-enable-lpd=true
# 指定最大文件数对于每个 bt 下载,默认 100
#bt-max-open-files=100
# 单种子最大连接数,默认 55
#bt-max-peers=55
# 设置最低的加密级别,可选全连接加密 arc4,默认是头加密 plain
#bt-min-crypto-level=plain
# 总是使用 obfuscation handshake,防迅雷必备,默认 false
bt-require-crypto=true
# 如果下载的是种子文件则自动解析并下载,默认 true
#follow-torrent=true
# 为 BT 下载设置 TCP 端口号,确保开放这些端口,默认 6881-6999
listen-port=65298
#Set UDP listening port used by DHT(IPv4, IPv6) and UDP tracker
dht-listen-port=65298
# 整体上传速度限制,0 表示不限制,默认 0
#max-overall-upload-limit=0
# 每个下载上传速度限制,默认 0
#max-upload-limit=0
# 种子分享率大于1, 则停止做种,默认 1.0
#seed-ratio=1
# 做种时间大于2小时,则停止做种
seed-time=120
# RPC 配置
# 开启 JSON-RPC/XML-RPC 服务,默认 false
enable-rpc=true
# 允许所有来源,web 界面跨域权限需要,默认 false
rpc-allow-origin-all=true
# 允许外部访问,默认 false
rpc-listen-all=true
# rpc 端口,默认 6800
rpc-listen-port=6800
# 设置最大的 JSON-RPC/XML-RPC 请求大小,默认 2M
#rpc-max-request-size=2M
# rpc 密码,可不设置
#rpc-passwd=raspberry
# rpc 用户名,可不设置
#rpc-user=aria2pi
# 高级配置
# This is useful if you have to use broken DNS and
# want to avoid terribly slow AAAA record lookup.
# 默认 false
disable-ipv6=true
# 指定文件分配方法,预分配能有效降低文件碎片,提高磁盘性能,缺点是预分配时间稍长
# 如果使用新的文件系统,例如 ext4 (with extents support), btrfs, xfs or NTFS(MinGW build only), falloc 是最好的选择
# 如果设置为 none,那么不预先分配文件空间,默认 prealloc
file-allocation=falloc
# 整体下载速度限制,默认 0
#max-overall-download-limit=0
# 每个下载下载速度限制,默认 0
#max-download-limit=0
# 保存错误或者未完成的下载到这个文件
# 和基本配置中的 input-file 一起使用,那么重启后仍可继续下载
save-session=/home/pi/.aria2/aria2.session
# 每5分钟自动保存错误或未完成的下载,如果为 0, 只有 aria2 正常退出才回保存,默认 0
save-session-interval=300
# 若要用于 PT 下载,需另外的配置,这里没写
RPC调用加入验证(外网调用最好加上验证),可以采用下面两种方式:
1) 使用token验证(建议使用,需要1.18.4以上版本,帐号密码方式将在后续版本中停用!)
# token验证
rpc-secret=secret
在YAAW中使用 http://token:secret@hostname:port/jsonrpc 的地址格式设置secret.
2 )如果需要使用密码验证(需要1.15.2以上,1.18.6以下版本)
#用户名
rpc-user=username
#密码
rpc-passwd=passwd
在YAAW中使用 http://username:passwd@hostname:port/jsonrpc 的地址格式设置密码.
3.运行 aria2, 测试配置是否有错误,如果没有提示任何错误信息,那就按Ctrl+C停止。
aria2c --conf-path=/home/pi/.aria2/aria2.conf
4.为 aria2 添加自启动服务
1) 新建 sudo vim /etc/init.d/aria2c 文件,输入以下内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /bin/sh
# /etc/init.d/aria2c
### BEGIN INIT INFO
# Provides: aria2c
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: aria2c RPC init script.
# Description: Starts and stops aria2 RPC services.
### END INIT INFO
#VAR
RUN="/usr/bin/aria2c"
ARIA_PID=$(ps ux | awk '/aria2c --daemon=true --enable-rpc/ && !/awk/ {print $2}')
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting script aria2c "
if [ -z "$ARIA_PID" ]; then
$RUN --daemon=true --enable-rpc=true -D --conf-path=/home/pi/.aria2/aria2.conf
echo "Started"
else
echo "aria2c already started"
fi
;;
stop)
echo "Stopping script aria2c"
if [ ! -z "$ARIA_PID" ]; then
kill $ARIA_PID
fi
echo "OK"
;;
restart)
echo "Restarting script aria2c"
if [ ! -z "$ARIA_PID" ]; then
kill $ARIA_PID
fi
sleep 3 # TODO:Maybe need to be adjust
$RUN --daemon=true --enable-rpc=true -D --conf-path=/home/pi/.aria2/aria2.conf
echo "OK"
;;
status)
if [ ! -z "$ARIA_PID" ]; then
echo "The aria2c is running with PID = "$ARIA_PID
else
echo "No process found for aria2c RPC"
fi
;;
*)
echo "Usage: /etc/init.d/aria2c {start|stop|restart|status}"
exit 1
;;
esac
exit 0
2) 添加可执行权限
sudo chmod +x /etc/init.d/aria2c
3) 然后更新rc,添加自启动服务
sudo update-rc.d aria2c defaults
4) 最后重启aria2c服务
sudo service aria2c restart
5.安装web 前端yaaw或者webui-aria2来实现web管理
yaaw 和 webui-aria2 都是不错的,yaaw 界面简洁,wubui-aria2 功能强大,可以根据自己的喜好来选择。
1) 首先需要安装需要安装 nginx
sudo apt-get install nginx –y
2) 接下来我们来配置nginx,首先打开配置文件,/etc/nginx/nginx.conf ,按照下面的配置进行修改。
1
2
3
4
5
6
7
8
9
10
11
user www-data; #默认以www-data运行工作进程
worker_processes 1; #单工作进程足够了,就我自己访问
worker_connections 256; #一般支持100在线连接就达到raspberry pi的极限了
gzip on; #gzip开启取消前面的#让默认设置生效即可,可以加快网页访问速度
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
3) 配置站点属性
sudo vim /etc/nginx/sites-availiable/default
输入,
server {
listen 81; # 访问端口号
#listen [::]:80 default_server; # 一定要注释掉,ipv6
server_name pi.com;
root /var/www/html; #站点存储位置
4) 测试配置文件看有没有问题
sudo nginx -t
如果没有问题会显示
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
5) 创建目录,然后设置权限
sudo mkdir /var/www && sudo mkdir /var/www/html
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 0755 /var/www/html
6) 下载webui-aria2
sudo git clone https://github.com/ziahamza/webui-aria2.git /var/www/html/
7) 重新启动nginx服务
sudo service nginx restart
到这一步了,现在我们通过http://192.168.1.118:81/webui-aria2/ 来访问,如果提示链接到aria2 RPC server失败,重启aria2c服务,然后刷新网页即可。
6.Aria2定时下载功能
1) 首先创建定时下载脚本,sudo vim /home/pi/.aria2/aria2_auto.py,输入如下内容,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python
import urllib2, json, time
WEEKDAY = int(time.strftime('%w'))
HOUR = int(time.strftime('%H'))
jsonreq_pauseAll = json.dumps({'jsonrpc':'2.0', 'id':'qwer','method':'aria2.pauseAll'})
jsonreq_unpauseAll = json.dumps({'jsonrpc':'2.0', 'id':'qwer','method':'aria2.unpauseAll'})
if WEEKDAY in [1,2,3,4,5]:
if HOUR == 1:
urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq_unpauseAll)
if HOUR == 17:
urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq_pauseAll)
if WEEKDAY in [6,0]:
if HOUR == 2:
urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq_unpauseAll)
if HOUR == 9:
urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq_pauseAll)
上面代码的意思就是周一到周五1:00~17:00,周末两天2:00~9:00,开启全部下载任务,其他时间暂停全部下载任务。然后加入cron实现定时运行
sudo crontab -e
在文件末尾加入
0 * * * * /usr/bin/python2 /home/pi/.aria2/aria2_auto.py
表示每个小时运行一次脚本。
7.BT端口映射
上面BT监听TCP, UDP端口都为65298,需要在路由器里面设置端口映射,服务端口号填65298,IP地址填树莓派内网IP地址192.168.1.118。
8.外网访问webui-aria2
下面会考虑三种典型的网络环境,前提都是路由器WAN是公网IP。
第一种网络环境:
Raspberry Pi的本地网络供应商80, 8080端口没有被封,从外网能正常访问,这个最简单了,修改树莓派nginx站点属性配置,把端口改为80, 然后在路由器上设置端口映射,80端口映射到树莓派上,然后路由器绑定动态域名,这样通过动态域名就可以在外网直接访问Aria2。
第二种网络环境:
Raspberry Pi的本地网络供应商80, 8080端口被封,你所在其他网络能正常访问外网,修改树莓派nginx站点属性配置,把端口改为81(或者其他能访问的端口),同样在路由上设置端口映射,绑定动态域名。
第三种网络环境:
Raspberry Pi的本地网络供应商80, 8080端口被封,公司只开放80, 8080端口。那么如何在公司畅快的远程下载呢?下面介绍我是如何实现的:
1) 首先需要有一台VPS,通过搭建nginx反向代理服务来实现远程下载。
配置nginx
sudo vim /etc/nginx/nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
user nginx;
worker_processes 1;
#error_log logs/error.log;
#pid logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
sendfile on;
keepalive_timeout 65;
gzip on;
client_max_body_size 50m;
client_body_buffer_size 256k;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_buffer_size 64k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_ignore_client_abort on;
}
2) 创建反向代理配置文件
sudo vim /etc/nginx/conf.d/reverser-proxy.conf
输入内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
server
{
listen 8080;
server_name xxx.xxx.xxx.xxx; #VPS IP Address
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://xxxx.oicp.net:6800; # RPC web address, http://xxxx.oicp.net 为动态域名
}
}
server
{
listen 80;
server_name xxx.xxx.xxx.xxx; #VPS IP Address
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://xxxx.oicp.net:81; #aria2 web gui
}
}
3) 路由器添加端口映射,81(webgui), 6800(rpc)端口。
4) 通过http://xxx.xxx.xxx.xxx 访问aria2 web gui, aria2采用token验证,通过http://token:secret@ xxx.xxx.xxx.xxx:8080/jsonrpc访问RPC, xxx.xxx.xxx.xxx为VPS IP地址。

这三种情况下都需要动态域名来绑定到路由器IP地址。关于动态域名,如果不清楚的,可以参考我后面的文章 Raspberry Pi从零开始搭建低成本NAS(9)-外网登录树莓派。里面会介绍动态域名,还会介绍不通过动态域名,如何在外网来访问树莓派。

Popular posts from 产品随想的博客

产品随想 | 周刊 第116期:Great things in business are never done by one person.

Cromite   https://github.com/uazo/cromite Cromite a Bromite fork with ad blocking and privacy enhancements; take back your browser! awesome-shizuku   https://github.com/timschneeb/awesome-shizuku Curated list of awesome Android apps making use of Shizuku KernelSU   https://github.com/tiann/KernelSU A Kernel based root solution for Android Love, Hate or Fear It, ​​TikTok Has Changed America   https://www.nytimes.com/interactive/2024/04/18/business/media/tiktok-ban-american-culture.html?unlocked_article_code=1.mE0.DpEZ.VWmNssw5B6_c "My model for business is The Beatles.There were four guys who kept each others, kind of, negative tendencies in check. They balanced each other, and the total was greater than the sum of the parts. And that's how I see business. You know, great things in business are never done by one person. They're done by a team of people. "Our motivation is simple--we want to provide the most advanced and innovative platform to our developers, and we wa...

产品随想 | 读《中国是部金融史》:第一章 此朝无钱胜有钱(周朝)

第一章 此朝无钱胜有钱(周朝) 姬旦选择了当时最有效、最简单的统治方式—一封建:为确保对国家的统治,姬且共封七十一国,其中姬姓五十三国,封国在地方替周王管理属国。 封建封建,封而建之。 对权力没有任何制约的西周,“王德〞是封建统治者最后的底线。这种“王德”对天命的畏惧延续了周王朝近千年的生命,此后,无论春秋五霸如何强盛,都只能挟天子以令诸侯,再强的诸候都必须获得王室认可。这一点,颇类似于西欧或者日本王位干年一系,绝不是“皇帝轮流做,明年到我家”的强盗逻辑。 司马迁之所以大骂周厉王,原因还在于周厉王推行了“专利”制度。其实,西周铭文甚至后世典籍始终都没说清楚究竟周厉王的“专利”是个什么东西,只是说他“专山林川泽之利”。周厉王很可能把诸候的山林川泽收归国有(自己所有),凡是在山上砍柴的、打猎的都要向王室纳税。看起来,周厉王敛财是确定无疑的,所以,司马迁认为此人是一个暴君。不是周厉王贪婪,而是王室实在太穷了。 西周王室失去了财富、失去了王德,也很快会失去江山。 失去“王德”的社会,人们只会臣服于强人,只有利益才是真正的信仰。也就是说, 这个时候的西周几乎是一种丛林社会,只有赤裸裸的暴力才能制约这些诸候了。对诸侯来说,周总王不过就是一个名号,没-起喝过酒、没一起拼过命,凭什么要听你的命令? ──复用下作者的句式:失去“法律”的社会,人们只会沉醉于拜金。 管仲告诉我们,强国、弱国最大的区别是强国的钱都在黎民百姓手里,弱国的钱却在国王的钱箱子里。这一点,颇类似于穷国和富国的区别,穷国只想抢老百姓的钱,富国却在想养如何让老百姓赚钱。 ──思考:我们的钱,在哪里? 周幽王死后,周平王为了躲避犬我,东迁至东都洛邑,中国开始了春秋时代。但无论春秋诸侯多么强盛,都要举起周王室大旗,所以,春秋在中国历史上也被称为“东周” 真正的强国,震慑敌闲的不只是万乘之师,还有无法超越的经济实力。强国经济之强,必然源自园内公平的经济环境,能为国民提供一个自由创造的空间。即使弱国拒绝承认强国的地位,甚至试图与强国平起平坐,也永远无法护绝强国对本土的经济渗透。 ──瞬间想到美国 无论弱国多么不情愿,强国货币都一定会流进他的地盘。在古代,一种曾经广泛流通的货币必然有大量文物存世,春秋货币则主要包括布币、刀币和蚁鼻钱三个体系。在中国史籍中经常提到“春秋五霸”,不过“春秋五霸”有很多种版本。顺着本书的逻辑, 我们...

《Becoming Steve Jobs》Chapter 15 The Whole Widget

What the world did see was an effective and visionary leader at the height of his powers. These were complicated years for Apple, but Steve handled almost every challenge in exactly the manner he wanted. He had fallen into leadership at such a young age, but he was comfortable in that role now, and justifiably sure of his capacity to guide Apple’s tens of thousands of employees to the goals he set for them. During these years, he would ensure the company’s continued success in personal computers by engineering a deft switch to a new kind of microprocessor; ruthlessly and successfully managing some major transitions in his executive team; and optimizing and building upon the efficiency and ambition of the company’s product development “treadmill,” as Tim Cook describes it. This is also when he delivered what is likely to be remembered as the most notable product of his life, the iPhone, and then improved even that by pivoting once again into a strategy he personally had not wanted to pu...

产品随想 | 周刊 第117期:He saw the intersection of art and science and business and built an organization to reflect that.

He disliked biography attempts. “I regard my scientific papers as my essential biography,’’ Land said. “I pour my whole life into the scientific project I’m investigating. I leave behind the things I’ve done in the past to do the work in the present.’’ “The purpose of inventing instant photography was essentially aesthetic,’’ Land said in 1947, announcing the process’s invention. “We live in a world changing so rapidly that what we mean frequently by common sense is doing the thing that would have been right last year.” — Edwin Land, Statement to Polaroid Corporation employees (25 June 1958) The worldview he was describing perfectly echoed Land’s: “Market research is what you do when your product isn’t any good.” And his sense of innovation: “Every significant invention,” Land once said, “must be startling, unexpected, and must come into a world that is not prepared for it. If the world were prepared for it, it would not be much of an invention.” Thirty years later, when a reporter ask...

Hacking Team武器库

之前百度盘上公开了部分Hacking Team工具,自己一直没有看懂,今天在泉哥博客上看到他对于武器库的几篇文章,mark一下

产品随想 | 周刊 第51期:Never let a good crisis go to waste

Products Paperless-ngx   https://github.com/paperless-ngx/paperless-ngx A community-supported supercharged version of paperless: scan, index and archive all your physical documents 自架设服务,文档聚合 Tube Archivist on YouTube   https://github.com/tubearchivist/tubearchivist Your self hosted YouTube media server 自托管YouTube流媒体播放 Emby Server Emby Server is a personal media server with apps on just about every device. 自己掌控流媒体 Pointless   https://github.com/kkoomen/pointless An endless drawing canvas desktop app made with Tauri (Rust) and React 无限画布白板工具,Tauri构建,跨多端 PWA LIST   https://www.pwalist.app/ 一些好玩的PWA应用,有些还不错 Pomofocus 番茄钟 Song Search “Find me a song by lyrics.”   https://songsear.ch/ Nanopi Openwrt   https://github.com/klever1988/nanopi-openwrt Openwrt for Nanopi R1S R2S R4S R5S 香橙派 R1 Plus 固件编译 纯净版与大杂烩 Project ImmortalWrt   https://github.com/immortalwrt/immortalwrt An opensource OpenWrt variant for mainland China users. China用户专用......心情复杂 YAOF   ht...

李录推荐阅读书单

李录推荐阅读书单 李录在《文明、现代化、价值投资和中国》的最后,列出了他推荐阅读的一些书目。这个书目的含金量非常之高,是培养一个多层次有深度思维很好的参考,特整理如下。 一. 科学、哲学、进化、人类文明史、人类历史 1. 《枪炮、病菌与钢铁:人类社会的命运》,贾雷德·戴蒙德 2. 《西方将主宰多久》,伊恩·莫里斯 3. 《文明的度量:社会发展如何决定国家命运》,伊恩·莫里斯 4. 《群的征服》,爱德华·奥斯本·威尔森 5. 《无穷的开始:世界进步的本源》,戴维·多伊奇 6. 《真实世界的脉络:平行宇宙及其寓意》,戴维·多伊奇 7. 《理性乐观派:一部人类经济进步史》,马特·里德利 8. 《科学发现的逻辑》,卡尔·波普尔 9. 《开放社会及其敌人》,卡尔·波普尔 10. 《自私的基因》,理查德·道金斯 11. 《人类简史:从动物到上帝》,尤瓦尔·赫拉利 12. 《文明》,尼尔·弗格森 13. 《当下的启蒙》,史蒂芬·平克 14. 《心智探奇:人类心智的起源与进化》,史蒂芬·平克 15. A history of knowledge, Charles Van Doren 16. 《神的历史》,凯伦·阿姆斯特朗 17. 《为什么佛学是真实的》,罗伯特·赖特 18. 《思考,快与慢》,丹尼尔·卡尼曼 19. Creating the Twentieth Century, Vaclav Smil 20. Transforming the Twentieth Century, Vaclav Smil 二. 中国文明、历史、文化 1. 《先秦诸子系年》,钱穆 2. 《中华文化十二讲》,钱穆 3. 《史记(白话本)》,司马迁 4. 《白话二十五史精选》,李解民等 5. 《四书章句集注》,朱熹 6. Waiting for the Dawn, William Theodore de Bary 7. 《中国的自由传统》,狄百瑞 8. 《万古江河——中国历史文化的转折和开展》,许倬云 9. 《黄宗羲全集》 10. 《余英时文集》 11. 《思想和人物》,林毓生 12. 《曾国藩全集》 13. 《万历十五年》,黄仁宇 14. 《天安门:知识分子与中国革命》,史景迁 15. The Search for Modern China, 史景迁 16. 《中国官僚政治研究》,王亚南 17. 《中...

《深度学习推荐系统》By 王喆

  推荐序言 深度学习/机器学习,爆发于2015年 算法能力+工程能力 1992年,施乐创建了应用协同过滤算法的推荐系统 本书for:推荐、广告、搜索领域的从业者/爱好者 第1章 互联网的增长引擎──推荐系统 不同业务模式的公司定义的具体推荐系统优化目标不同,例如,视频类公司更注重用户观看时长,电商类公司更注重用户的购买转化率(Conversion Rate,CVR ) YouTube推荐系统的主要优化目标就是观看时长,而不是CTR 工程论文:Deep Neural Networks for YouTube Recommenders 大致流程:构建深度学习模型,预测用户观看某候选视频的时长,按照预测时长进行候选视频的排序,形成最终的推荐列表 淘宝首页:千人千面(即使是1%的CTR提高,也会到来数十亿元收入增加) 推荐系统逻辑框架:f(U,I,C), User, Item, Context 推荐系统数据部分:实时数据、准实时数据、离线数据 推荐系统模型部分:召回层、排序层、补充策略与算法层(排序层是工业界与学术界研究的核心) 第2章 前深度学习时代──推荐系统的进化之路 UserCF: 基于用户相似度进行推荐的协同过滤算法 互联网用户数的增长会导致矩阵维护复杂度急剧上升 用户的历史数据可能稀疏(导致UserCF不适用于酒店预订、大件商品购买等低频应用) 适用于发现热点、以及跟踪热点的趋势 ItemCF:基于物品相似度进行推荐的协同过滤算法 更适用于兴趣变化较为稳定的应用 协同过滤的天然缺陷:推荐结果的头部效应较明显 其它模型:矩阵分解、逻辑回归、FM、FFM、GBDT+LR、LS-PLM (细节已经要看不懂了) 第3章 浪潮之巅──深度学习在推荐系统中的应用 Google Play的推荐团队,基于对业务场景的深刻理解,提出了Wide&Deep模型 这张属于看不懂那种类型 第4章 Embedding技术在推荐系统中的应用 Not Interested 第5章 多角度审视推荐系统 从7个不同的角度切入推荐系统 推荐系统如何选取和处理特征 召回层的主要策略有哪些? 实时性的重要性体现在哪里?有哪些提高实时性的方法? 如何根据具体场景构建推荐模型的优化目标 如何基于用户动机改进模型结构 冷启动问题的解决方法有哪些 什么是探索与利用问题?有哪些主流的解决方法 第...

Bilibili Q2 2023 Earnings Call Transcript

Moving on to our community growth. Our DAUs increased by 15% year-over-year to 96.5 million in the second quarter, driving our DAU to MAU ratio up to 29.8%. In the second half of this year, we plan to shift our video watching metric from video views to video time spent, which will help our users discover more high-quality content on Bilibili. In addition, we are exploring new live broadcasting products to create more paying channels for our users, including live celebration events. We expect our ongoing integration activities to support our revenue growth in the second half of 2023. Our top five advertising verticals in the second quarter were games, e-commerce, digital products and home appliances, skincare and cosmetics, and food and beverage. 五大Top广告垂类 In the meantime, we have seven new titles that we plan to release in domestic and overseas markets in the second half of the year, including the highly anticipated game Pretty Derby 期待7款游戏能红火一波 We cut sales and marketing expenses by 2...

产品随想 | 陪读《芯片战争》:一、二章

作者其它书也值得读读 已出版《食用油营销第1书》《金龙鱼背后的粮油帝国》《鲁花:一粒花生撬动的粮油帝国》《手机战争》等财经书籍。 第一章 从晶体管到芯片 肖克利要创业的消息,就像17世纪的牛顿宣布要建立工场一样引起了轰动。那时候,美国还在草创时期的半导体产业主要集中在东部的波士顿和纽约长岛地区,许多科学家和工程师精英都慕肖克利之名前往美国西海岸,不远千里地聚集在肖克利旗下。可以这么说,肖克利给硅谷带来了最初的火种。 ——我也認可這個說法,不是斯坦福或其他校園,純粹是人才的原因 芯片发明后的六年间,政府对芯片项目的资助高达3200万美元,其中70%来自空军。同期美国半导体产业的研发经费有约85%的比例来自政府,政府的支持成就了美国在半导体领域的技术优势。“华盛顿通过支付技术研发费用和保证最终产品的市场份额,将原子弹最终制造成功的间隔缩短至六年,晶体管缩短至五年,集成电路缩短至三年。”不过,这些半导体企业实力壮大以后,往往不愿再参与美国政府出资的研发项目,因为那意味着专利权归政府所有,而且还得受保密条款的约束。 ——這纔是更合理的產業支持政策 诺伊斯采用激进的价格政策,将主要芯片产品的价格一举降到1美元,不仅是市场上的主流芯片价格的零头,还低于当时芯片的成本。这不是传统意义上的亏本倾销,而是第一个以反摩尔定律为定价依据的案例。反摩尔定律认为,同样的芯片在18个月后价格就会跌一半,所以按照几年后的价格为当前的芯片定价是有一定合理性的。市场被迅速打开,芯片很快在民用市场得到越来越广泛的应用,仙童的营收和利润都迅速上升,还带动了其母公司的股价上涨。摩尔后来评论:“诺伊斯以低价刺激需求,继而扩大产能、降低成本的策略,对于芯片产业的发展而言,其重要性堪比芯片的发明。” ——看到這裏的時候,真是非常震撼,好厲害的定價策略 东通工用磷渗透法研发出了高频的晶体管,于1957年做出世界上第一款袖珍收音机,并在这款产品上启用了索尼商标。盛田昭夫到美国去推销袖珍收音机的时候,德州仪器刚刚轻率地放弃了这个市场。美国人对盛田昭夫说:你们为什么要制造这种小收音机?美国人都想要大收音机。盛田昭夫回答:单单纽约就有20多家广播公司,同时就有20多套节目在播放,每人使用一台小收音机收听自己喜欢的节目,岂不更好?索尼用“一人一台”的宣传成功打破了美国人全家共用一台大型收音机的观念,成为全世界最畅销的收音机...