The configuration details are as follows.
Property | Type | Description | Default value |
---|---|---|---|
sofa_runtime_local_mode |
BOOLEAN | The switch for local call preference. | false |
run_mode |
STRING | The RPC running mode. | null |
rpc_tr_port |
INTEGER | The TR port number. | 12200 |
rpc_bind_network_interface |
STRING | The fixed network interface bound to the server. | null |
rpc_enabled_ip_range |
STRING | The range of local IP addresses bound to the server. | null |
rpc_min_pool_size_tr |
INTEGER | The minimum number of threads in the thread pool of the TR server. | 20 |
rpc_max_pool_size_tr |
INTEGER | The maximum number of threads in the thread pool of the TR server. | 200 |
rpc_pool_queue_size_tr |
INTEGER | The queue size of the thread pool of the TR server. | 0 |
com.alipay.sofa.rpc.bolt.port |
INTEGER | * The Bolt port number. | 12200 |
com.alipay.sofa.rpc.bolt.thread.pool.core.size |
INTEGER | * The minimum number of threads in the thread pool of the Bolt server. | 20 |
com.alipay.sofa.rpc.bolt.thread.pool.max.size |
INTEGER | * The maximum number of threads in the thread pool of the Bolt server. | 200 |
com.alipay.sofa.rpc.bolt.thread.pool.queue.size |
INTEGER | * The queue size of the thread pool of the BOLT server. | 0 |
com.alipay.sofa.rpc.rest.port |
INTEGER | The SOFAREST port number. | 8341 |
rpc_transmit_url |
STRING | The preloading and weight configuration. | null |
rpc_transmit_url_timeout_tr |
INTEGER | The timeout period of preloading, in ms. | 0 |
rpc_profile_threshold_tr |
INTEGER | The print threshold of RPC service performance logs, in ms. | 300 |
Priority Configuration of Local Invocation
When multiple apps are started locally, to make them call each other first without SLB, you just need to add sofa_runtime_local_mode=true
to application.properties
.
However, sofa_runtime_local_mode
still depends on the IP addresses pushed by the configuration center. After obtaining the IP address list of service providers, the consumer prefer local IP addresses for service calling. If the workspace where the developer is located does not provide a configuration center, the service provider IP address needs to be specified for calling. For more information, see Routing and configuration center.
application.properties: run_mode=TEST
<! -- Service consumer configuration -->
<sofa:reference ...>
<sofa:binding.bolt>
<global-attrs test-url="localhost:12200" />
</sofa:binding.bolt>
</sofa:reference>
IP address / NIC binding
When publishing a service IP address, SOFARPC publishes the IP address of the first local network interface to the configuration center. If several network interfaces (for example, the SOFAStack platform includes LAN IP addresses and Internet IP addresses) are available, you need to set an IP address selection strategy.
SOFARPC provides two methods to select an IP address:
rpc_bind_network_interface
Choose an IP address by specifying the network interface name:
rpc_bind_network_interface=eth0
.rpc_enabled_ip_range
Specify the IP address range for binding. Format:
IP_RANGE1:IP_RANGE2,IP_RANGE
. For example,rpc_enabled_ip_range=10.1:10.2,11
means the IP address can only be selected from10.1.0.0 ~ 10.2.255.255
and11.0.0.0 ~ 11.255.255.255
.
Note: The LAN IP addresses on the SOFAStack platform are all bound to network interface eth0. We recommend that you use
rpc_bind_network_interface=eth0
directly. If you run an app on a platform other than SOFAStack, check the LAN IP addresses of the server to decide what configuration you should use. The command for viewing the IP address of the server:ipconfig
for Windows systems, andifconfig
for Mac/Linux systems.
TR Thread pool Configuration
In the application.properties
file, use the following options to configure the TR thread pool:
com.alipay.sofa.rpc.bolt.thread.pool.core.size
: the minimum number of threads, which is 20 by defaultcom.alipay.sofa.rpc.bolt.thread.pool.max.size
: the maximum number of threads, which is 200 by defaultcom.alipay.sofa.rpc.bolt.thread.pool.queue.size
: the queue size, which is 0 by default
TR adopts the thread pool ThreadPoolExecutor
of JDK. If being extended, the core thread pool first expands to the size with the minimum number of threads. When concurrent requests surpass the minimum number of threads, the excessive requests wait in a queue. When the queue is full, the thread pool expands to the size with the maximum number of threads. When the requests exceed the maximum number of threads, the RejectionException
exception is thrown.
Log Configuration
For more information, see Log description.