Redis
Redis can be utilized to enhance performance and scalability by serving as a caching layer to store frequently accessed data, reducing database load and response times. Additionally, Redis can be employed for session management, real-time analytics, and inter-service communication, making it a versatile tool for improving the efficiency and responsiveness.
Configuring Redis
Configuring Redis for Martini Server Runtime involves setting up Redis to enhance application performance and data management effectively. Begin by installing Redis on your server or using a managed Redis service. Proper configuration ensures that Redis integrates seamlessly with Martini, delivering fast and reliable data access and improving overall application efficiency. Here’s a straightforward guide to adding a new database connection:
Configuration Guide
Via API Explorer: Database connections can be configured using the Martini API Explorer, a user-friendly interface designed for efficient interaction with the system's APIs. Follow these steps to configure the database connections through the API Explorer:
-
Access the API Explorer: Open a web browser and go to
[HOST]:8080/api-explorer/
to access the API Explorer. -
Navigate to the Database Tag: Locate and click on the
database
tag within the API Explorer to view various database configuration and operation endpoints. -
Configure Connection Pool: Use the
esbapi/databases
endpoint found under the database tag to save a database connection pool. -
Use POST to Save a Connection Pool: Save the connection pool by using the POST method at the
/esbapi/databases
endpoint. Here is a minimum requirement for a JSON payload:1 2 3 4 5
{ "name": "[name]", "type": "redis", "uri": "redis://<HOST>:6379/" }
Via File System:
Alternatively, database connections can be modified directly in the file system by editing the
To modify database connections directly through the file system, follow these steps:
-
Locate the Configuration File: Navigate to the
/<martini-home>/conf/db-pool/
directory on your server and locate the<name>.dbxml
file. -
Edit the Database Connections: Open the
<name>.dbxml
file in a text editor and modify the database connection properties. -
Save and Restart: After making the desired changes, save the file. It is essential to restart the Martini Runtime instance to apply the new settings. This ensures that all components of the application use the updated Redis configuration. Here is a minimum requirement for a dbXML:
1 2 3 4 5
<database> <name>[name]</name> <type>redis</type> <uri>redis://[HOST]:6379/</uri> <database>
Configuring Redis in Martini Designer
- Navigate to the Navigator view and right-click on the Databases node of the instance where you intend to add the database connection.
- Choose New > Database Connection.
- Specify a name for the connection and select the database type Redis.
- Fill in the database connection details in the provided form.
- Save the changes.
Database Properties
The table below outlines the configurable properties for a database connection:
General Configuration
This section defines the core settings of the connection, such as the name, type, URI, and whether the connection starts automatically. It includes fundamental parameters like the connection's password and its current status.
Field Name | Parameter | Required | Default Value | Description |
---|---|---|---|---|
Name | name |
true | null | The name of the database connection. |
Auto Start | autoStart |
false | false | Specifies whether the connection auto starts. |
Status | status |
false | null | Current status of the connection. |
Type | type |
true | null | Type of the connection (e.g., redis). |
URI | uri |
true | null | URI of the Redis connection. |
Password | password |
false | null | Password for the Redis connection. |
Client Options
These are configurations that govern how the Redis client behaves. They cover options like automatic reconnection, how commands are handled during reconnections, the size of the request queue, and behavior during disconnections.
Field Name | Parameter | Required | Default Value | Description |
---|---|---|---|---|
Ping Before Activate Connection | pingBeforeActivateConnection |
false | true | Whether to ping before activating the connection. |
Auto Reconnect | autoReconnect |
false | true | Automatically reconnects if the connection is lost. |
Cancel Commands on Reconnect Failure | cancelCommandsOnReconnectFailure |
false | true | Cancels commands if reconnection fails. |
Publish on Scheduler | publishOnScheduler |
false | true | Publish commands on the scheduler. |
Suspend Reconnect on Protocol Failure | suspendReconnectOnProtocolFailure |
false | true | Suspends reconnection on protocol failure. |
Request Queue Size | requestQueueSize |
false | 2147483647 | Maximum size of the request queue. |
Disconnected Behavior | disconnectedBehavior |
false | DEFAULT | Defines behavior when disconnected. |
Socket Options
Socket options control the low-level network settings for the connection. These include connection timeouts, keep-alive settings to maintain the connection, and whether TCP delays should be applied.
Field Name | Parameter | Required | Default Value | Description |
---|---|---|---|---|
Connect Timeout | connectTimeoutMillis |
false | 10000 | Socket connection timeout in milliseconds. |
Keep Alive | keepAlive |
false | false | Enables or disables socket keep-alive. |
TCP No Delay | tcpNoDelay |
false | false | Disables Nagle’s algorithm (TCP delay). |
SSL Options
This section manages settings related to securing the connection with SSL (Secure Sockets Layer). It includes the SSL provider and whether to use StartTLS, which upgrades a plain connection to a secure one.
Field Name | Parameter | Required | Default Value | Description |
---|---|---|---|---|
SSL Provider | sslProvider |
false | JDK | SSL provider to use, e.g., JDK. |
Start TLS | startTls |
false | false | Whether to start TLS. |
Connection Options
These options define how commands and connections are handled at the protocol level. This includes whether commands should be flushed automatically and the timeout for establishing a connection.
Field Name | Parameter | Required | Default Value | Description |
---|---|---|---|---|
Auto Flush Commands | autoFlushCommands |
false | true | Auto-flushes commands. |
Connection Timeout | connectionTimeoutMillis |
false | -1 | Timeout for the connection in milliseconds. |
Connection Pool Options
Connection pool options manage how Redis handles a pool of connections. This includes the total number of connections, idle connection management, the order of connections (LIFO), and settings for testing, evicting, or waiting on connections. It ensures efficient resource management when using multiple connections.
Field Name | Parameter | Required | Default Value | Description |
---|---|---|---|---|
Max Total Pool Connections | maxTotal |
false | 8 | Maximum total connections in the pool. |
Max Idle Pool Connections | maxIdle |
false | 8 | Maximum idle connections in the pool. |
Min Idle Pool Connections | minIdle |
false | 0 | Minimum idle connections in the pool. |
LIFO Pool Order | lifo |
false | true | Whether the pool uses a LIFO (Last In, First Out) order. |
Fairness Pool Option | fairness |
false | false | Whether the pool enforces fairness. |
Max Wait Time for Pool | maxWaitMillis |
false | 0 | Max wait time for acquiring a connection in milliseconds. |
Min Evictable Idle Time | minEvictableIdleTimeMillis |
false | 1800000 | Min idle time before eviction in milliseconds. |
Soft Min Evictable Idle Time | softMinEvictableIdleTimeMillis |
false | -1 | Soft minimum idle time before eviction. |
Num Tests Per Eviction Run | numTestsPerEvictionRun |
false | 3 | Number of connections tested for eviction during each run. |
Evictor Shutdown Timeout | evictorShutdownTimeoutMillis |
false | 10000 | Time for evictor shutdown in milliseconds. |
Test on Create | testOnCreate |
false | false | Tests connections when created. |
Test on Borrow | testOnBorrow |
false | false | Tests connections when borrowed from the pool. |
Test on Return | testOnReturn |
false | false | Tests connections when returned to the pool. |
Test While Idle | testWhileIdle |
false | false | Tests idle connections. |
Time Between Eviction Runs | timeBetweenEvictionRunsMillis |
false | -1 | Time between eviction runs in milliseconds. |
Block When Exhausted | blockWhenExhausted |
false | true | Blocks when no available connections. |
JMX Enabled | jmxEnabled |
false | false | Enables or disables JMX monitoring. |