F-Stack / f-stack

F-Stack is an user space network development kit with high performance based on DPDK, FreeBSD TCP/IP stack and coroutine API.
http://www.f-stack.org
Other
3.8k stars 886 forks source link

Start Redis multi instance #329

Open alvyC opened 5 years ago

alvyC commented 5 years ago

Hi, I know that previously it was not supported. Does fstack-based redis app support multi instances now? I am trying to do the following:

./app/redis-3.2.8/src/redis-server --conf config.ini --proc-type=primary --procid=0 redis-1.conf &
./app/redis-3.2.8/src/redis-server --conf config.ini --proc-type=secondary --procid=1 redis-2.conf &

But getting error. Just want to make sure, the problem is not at my end.

whl739 commented 5 years ago

Could you show me the error information?

alvyC commented 5 years ago

Getting the following error:

f-stack -c2 -n4 --proc-type=primary EAL: Probing VFIO support...
[dpdk]: lcore_mask=2
parse config.ini failed on line 3

Config.ini:

[dpdk]
# Hexadecimal bitmask of cores to run on.
lcore_mask=2

# Number of memory channels.
channel=4

# Specify base virtual address to map.
#base_virtaddr=0x7f0000000000

# Promiscuous mode of nic, defualt: enabled.
promiscuous=1
numa_on=0

# TCP segment offload, default: disabled.
tso=0

# HW vlan strip, default: enabled.
vlan_strip=1

# sleep when no pkts incomming
# unit: microseconds
idle_sleep=0

# enabled port list
#
# EBNF grammar:
#
#    exp      ::= num_list {"," num_list}
#    num_list ::= <num> | <range>
#    range    ::= <num>"-"<num>
#    num      ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
#
# examples
#    0-3       ports 0, 1,2,3 are enabled
#    1-3,4,7   ports 1,2,3,4,7 are enabled
port_list=0

# Number of vdev.
nb_vdev=0

# Port config section
# Correspond to dpdk.port_list's index: port0, port1...
[port0]
addr=192.168.232.50
netmask=255.255.225.0
broadcast=192.168.232.255
gateway=0.0.0.0

# lcore list used to handle this port
# the format is same as port_list
#lcore_list= 0-1

redis-1.conf:

bind 192.168.232.50
port 9001

redis-2.conf

bind 192.168.232.50
port 9002

Only the primary process is running. FYI, I am using the same interface.

whl739 commented 5 years ago

--procid is wrong, it should be --proc-id. lcore_mask means hexadecimal bitmask of cores to run on, lcore_mask=2 means that use cpu1 to run, in your case, it can be 3 (which is 11 in bitmask).

alvyC commented 5 years ago

Hi, With these changes I got the two server running. But another problem is, when I am sending request from client machine, only half of the request are getting response. It is because of RSS offloading. Requests which should go to server 1(port 9001, core 0) is going to server 2 (port 9002, core 1). Do you have any solution for this?

whl739 commented 5 years ago

Rss offloading will lead this problem, and we have an solution for this. See https://github.com/F-Stack/f-stack/issues/231#issuecomment-396201683.

alvyC commented 5 years ago

Thanks for the pointer. Please correct me if I am wrong. I think I have to declare and register the dispatch function in the redis code.

Is there any example dispatcher function I can look at?

whl739 commented 5 years ago

Thanks for the pointer. Please correct me if I am wrong. I think I have to declare and register the dispatch function in the redis code.

Yes, you should modify the redis code, you can add it before ff_init.

Is there any example dispatcher function I can look at?

Sorry, no example now.

victorstewart commented 5 years ago

how does the --proc-id option enable support for running multiple Redis instances that's not otherwise supported? Or is it now supported?

and if it isn't, how much work would be involved adding support for running multiple independent processes all using f-stack / listening on different ports?

alvyC commented 5 years ago

--proc-id is used for starting multiple fstack-based app. See this comment to get an idea about how it has to done