Thin Client
Lightweight client connection
Thin Client is a lightweight Ignite connection mode. It does not start in JVM process (Java is not required at all), does not participate in cluster, never holds any data, or performs computations.
What it does is establish a socket connection to an individual Ignite node, and perform all operations through that node.
Thin Client mode is perfect for short-lived and resource-restricted applications, memory and CPU usage is minimal.
Installation
Thin client API is located in the same Apache.Ignite.Core
assembly (Apache.Ignite
NuGet package) and shares many classes and interfaces with full Ignite.NET API, so you can easily switch from one API to another. Basic installation procedure is the same: Getting Started.
Requirements
Even though assembly and NuGet package are the same, requirements are different:
- Java is NOT required
- Supported runtimes: .NET 4.0+, .NET Core 2.0+
- Supported OS: Windows, Linux, macOS (any OS supported by .NET Core 2.0+)
Use multiple threads with thin client connection pool to improve performance
Presently the .NET thin client has no feature to create multiple threads to improve throughput. You can create multiple threads by getting a thin client connection from a pool in your application to improve throughput.
Configuring Server Nodes
Thin client connector is enabled in Ignite server nodes by default. It can be disabled by setting IgniteConfiguration.ClientConnectorConfigurationEnabled
to false
in .NET, or IgniteConfiguration.clientConnectorConfiguration
to null
in Java or Spring XML.
Connector settings can be adjusted like this:
var cfg = new IgniteConfiguration
{
ClientConnectorConfiguration = new ClientConnectorConfiguration
{
Host = "myHost",
MaxOpenCursorsPerConnection = 64,
Port = 10900,
PortRange = 50
}
};
<igniteConfiguration>
<clientConnectorConfiguration host='myHost' port='10900' portRange='50' maxOpenCursorsPerConnection='50' />
</igniteConfiguration>
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="clientConnectorConfiguration">
<bean class="org.apache.ignite.configuration.ClientConnectorConfiguration">
<property name="host" value="myHost"/>
<property name="port" value="11110"/>
<property name="portRange" value="30"/>
</bean>
</property>
</bean>
Connecting to Cluster
The thin client API entry point is the Ignition.StartClient(IgniteClientConfiguration)
method. The IgniteClientConfiguration.Host
property is mandatory; it should point to a host where the Ignite server node is running. Other properties should correspond to ClientConnectorConfiguration
of the server node.
Given that the server node runs locally, and ClientConnectorConfiguration
is default:
var cfg = new IgniteClientConfiguration
{
Host = "127.0.0.1"
};
using (IIgniteClient client = Ignition.StartClient(cfg))
{
ICacheClient<int, string> cache = client.GetCache<int, string>("cache");
cache.Put(1, "Hello, World!");
}
Authentication
User credentials must be provided if authentication is enabled on the server.
var cfg = new IgniteClientConfiguration
{
Host = "127.0.0.1",
Port = 10900,
UserName = "ignite",
Password = "kg1mmcoXZU"
};
using (IIgniteClient client = Ignition.StartClient(cfg))
{
ICacheClient<int, string> cache = client.GetCache<int, string>("cache");
cache.Put(1, "Hello, World!");
}
Partition Awareness
Partition awareness allows the thin client to send query requests directly to the node that owns the queried data. The client, as it were, is aware of the partition distribution.
Without partition awareness, an application that is connected to the cluster via a thin client executes all queries and operations via a single server node that acts as a proxy for the incoming requests. That node re-routes the operations to the node that stores the data that is being requested. This results in a bottleneck that adds additional latency.
With partition awareness in place, the thin client can directly send queries and operations to the nodes that own the data required for the queries. This eliminates the bottleneck, allowing the application to scale more easily.
To enable partition awareness, set the IgniteClientConfiguration.EnablePartitionAwareness
property to true
and provide addresses of multiple server nodes in the client’s connection configuration.
Thin Client APIs
Thin client offers a subset of full Ignite.NET APIs. It is evolving and we plan to support most APIs in both thick and thin clients in the future.
Current version supports Cache API ICacheClient
, including ScanQuery
with predicate.
Updated over 5 years ago