As of January 2025, v2fly's v2ray-core does not support rate limiting. To limit a user's download and upload rate, we can configure v2ray to mark the download and upload traffic with fwmark, then limit the rate of that traffic using Linux traffic control. We need to assign an inbound and outbound instance to each user to be able to do rate limiting per user.
/usr/local/etc/v2ray/config.json
Traffic control for three users, each assigned a download and upload limit of 50 Mbps, 100 Mbps, or 200 Mbps.
# Replace the root qdisc for the internet interface to HTB.
sudo tc qdisc replace dev eth0 root handle 1:0 htb
# Add three classes for HTB, to rate limit to 50mbit, 100mbit, or 200mbit.
sudo tc class add dev eth0 parent 1:0 classid 1:1 htb rate 50mbit
sudo tc class add dev eth0 parent 1:0 classid 1:2 htb rate 100mbit
sudo tc class add dev eth0 parent 1:0 classid 1:3 htb rate 200mbit
# Limit download rate of users
sudo tc filter add dev eth0 parent 1:0 handle 1 fw classid 1:1
sudo tc filter add dev eth0 parent 1:0 handle 2 fw classid 1:2
sudo tc filter add dev eth0 parent 1:0 handle 3 fw classid 1:3
# Limit upload rate of users
sudo tc filter add dev eth0 parent 1:0 handle 501 fw classid 1:1
sudo tc filter add dev eth0 parent 1:0 handle 502 fw classid 1:2
sudo tc filter add dev eth0 parent 1:0 handle 503 fw classid 1:3