This topic describes the available configuration items and common configurations for SOFARPC.
Basic configuration items
Add the following configuration items to the application.properties file as needed for your environment:
Configuration item | Type | Description | Default value |
| BOOLEAN | Enables or disables local-first invocation. | false |
| STRING | The RPC running mode. Set this based on your actual environment. | empty |
| INTEGER | The TR port number. | 12200 |
| STRING | Binds the server to a specific network interface controller (NIC). | empty |
| STRING | Binds the server to a local IP address range. | empty |
| INTEGER | The minimum number of threads in the TR server thread pool. | 20 |
| INTEGER | The maximum number of threads in the TR server thread pool. | 200 |
| INTEGER | The queue size of the TR server thread pool. | 0 |
| INTEGER | The Bolt port number. | 12200 |
| INTEGER | The minimum number of threads in the Bolt server thread pool. | 20 |
| INTEGER | The maximum number of threads in the Bolt server thread pool. | 200 |
| INTEGER | The queue size of the Bolt server thread pool. | 0 |
| INTEGER | The SOFAREST port number. | 8341 |
| STRING | Configuration for prefetch and weight. | empty |
| INTEGER | The timeout period for prefetch calls, in ms. | 0 |
| INTEGER | The threshold for printing RPC service processing performance logs, in ms. | 300 |
Local-first invocation pattern
To prioritize local service invocations between multiple SOFA applications and bypass software load balancing, add sofa_runtime_local_mode=true to the application.properties file.
However, the sofa_runtime_local_mode configuration still depends on the addresses pushed from the configuration center. After obtaining the list of service provider addresses, the service consumer prioritizes the local IP address for service invocation. If a developer's workspace does not have a configuration center, you must specify the service provider's address for the invocation. 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 or NIC binding
By default, when SOFARPC publishes a service endpoint, it selects the IP address of the first local NIC to publish to the configuration center. If multiple NICs are present, such as on the SOFAStack platform where both private and public IP addresses exist, you must set an IP selection policy.
SOFARPC provides two ways to select an IP address:
rpc_bind_network_interfaceSpecify the NIC name to use, for example:
rpc_bind_network_interface=eth0.rpc_enabled_ip_rangeSpecify an IP address range to bind. The format is
IP_RANGE1:IP_RANGE2,IP_RANGE. For example,rpc_enabled_ip_range=192.168.1:192.168.2,10means that only IP addresses in the ranges192.168.1.0to192.168.2.255and10.0.0.0to10.255.255.255are selected.NoteOn the SOFAStack platform, all private network addresses are bound to the eth0 NIC. You can use the
rpc_bind_network_interface=eth0configuration directly. If the application runs on a platform other than SOFAStack, check the machine's private network address and modify the configuration accordingly. You can use the following commands to view the machine's address:Windows:
ipconfigmacOS and Linux:
ifconfig
TR thread pool configuration
You can use the following options in the application.properties file to configure the TR thread pool:
com.alipay.sofa.rpc.bolt.thread.pool.core.size: The number of core threads. The default is 20.com.alipay.sofa.rpc.bolt.thread.pool.max.size: The maximum number of threads. The default is 200.com.alipay.sofa.rpc.bolt.thread.pool.queue.size: The size of the thread queue. The default is 0.
TR uses the ThreadPoolExecutor from the Java Development Kit (JDK). When new requests arrive, the pool creates threads up to the core thread count. After the core thread count is reached, new requests are placed in the thread queue. If the queue becomes full, the pool creates additional threads up to the maximum thread count. If the maximum thread count is reached and the queue is full, subsequent requests are rejected with a RejectionException.