<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.spiretrading.com/index.php?action=history&amp;feed=atom&amp;title=Market_Data_Relay_Server</id>
	<title>Market Data Relay Server - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.spiretrading.com/index.php?action=history&amp;feed=atom&amp;title=Market_Data_Relay_Server"/>
	<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Market_Data_Relay_Server&amp;action=history"/>
	<updated>2026-05-29T21:32:44Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Market_Data_Relay_Server&amp;diff=137&amp;oldid=prev</id>
		<title>Kamal: Created page with &quot;The Market Data Relay Server provides load-balanced distribution of market data to end users. It acts as an intermediary layer between the Market Data Server and client ap...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Market_Data_Relay_Server&amp;diff=137&amp;oldid=prev"/>
		<updated>2026-05-27T19:56:18Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;The Market Data Relay Server provides load-balanced distribution of market data to end users. It acts as an intermediary layer between the &lt;a href=&quot;/index.php/Market_Data_Server&quot; title=&quot;Market Data Server&quot;&gt;Market Data Server&lt;/a&gt; and client ap...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The Market Data Relay Server provides load-balanced distribution of market data to end users. It acts as an intermediary layer between the [[Market Data Server]] and client applications, receiving market data updates from the Market Data Server and relaying them to subscribed clients. By deploying multiple relay servers in parallel, the system can distribute client connections across instances, ensuring scalable and resilient market data delivery.&lt;br /&gt;
&lt;br /&gt;
The Market Data Relay Server integrates with the [[Service Locator]] for authentication and service registration. Multiple relay servers can operate concurrently to distribute load across the infrastructure.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
The Market Data Relay Server is configured via a YAML file with two top-level sections (&amp;lt;code&amp;gt;server&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;service_locator&amp;lt;/code&amp;gt;) plus optional tuning parameters. Below is the structure of the configuration file with example values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server:&lt;br /&gt;
  # Primary network interface and port the Market Data Relay Server binds to.&lt;br /&gt;
  interface: &amp;quot;0.0.0.0:22300&amp;quot;&lt;br /&gt;
  # List of addresses the server is reachable at (for registration with Service Locator).&lt;br /&gt;
  # Typically includes both public-facing and local addresses.&lt;br /&gt;
  addresses: [&amp;quot;198.51.100.5:22300&amp;quot;, &amp;quot;10.0.0.5:22300&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
service_locator:&lt;br /&gt;
  # The address of the Service Locator (host:port).&lt;br /&gt;
  address: &amp;quot;10.0.0.5:20000&amp;quot;&lt;br /&gt;
  # The account username used by the Market Data Relay Server to authenticate with the Service Locator.&lt;br /&gt;
  username: market_data_relay_server&lt;br /&gt;
  # The password for the Market Data Relay Server's Service Locator account.&lt;br /&gt;
  password: [REQUIRED]&lt;br /&gt;
&lt;br /&gt;
# Optional timeout for upstream Market Data Server connections (default: 500 ms).&lt;br /&gt;
connection_timeout: 500ms&lt;br /&gt;
&lt;br /&gt;
# Optional minimum pool size for upstream connections (default: hardware concurrency).&lt;br /&gt;
min_connections: 8&lt;br /&gt;
&lt;br /&gt;
# Optional maximum pool size for upstream connections (default: 10 * min_connections).&lt;br /&gt;
max_connections: 80&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script is provided to generate the final &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;config.default.yml&amp;lt;/code&amp;gt; template. Usage:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  --local 0.0.0.0           # Local interface (default: auto-detected IP)&lt;br /&gt;
  --world 198.51.100.5      # Global/public interface (optional)&lt;br /&gt;
  --address 10.0.0.5:20000  # Service Locator address (default: local_interface:20000)&lt;br /&gt;
  --password [REQUIRED]     # Service password for authentication&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture ==&lt;br /&gt;
&lt;br /&gt;
The market data distribution architecture consists of three tiers:&lt;br /&gt;
&lt;br /&gt;
# '''Feed Clients''' publish raw market data to the Market Data Server.&lt;br /&gt;
# '''Market Data Server''' organizes, sequences, and persists market data.&lt;br /&gt;
# '''Market Data Relay Servers''' distribute market data to end-user clients.&lt;br /&gt;
&lt;br /&gt;
This architecture separates data processing from distribution, allowing the Market Data Server to focus on sequencing and storage while relay servers handle the potentially large number of client connections. Multiple relay servers can be deployed to distribute client load geographically or by capacity requirements.&lt;br /&gt;
&lt;br /&gt;
When multiple Market Data Servers are registered with the Service Locator (each potentially serving different country scopes), the relay server connects to all of them and routes client subscriptions to the appropriate upstream based on the country associated with each security.&lt;br /&gt;
&lt;br /&gt;
== Management ==&lt;br /&gt;
&lt;br /&gt;
The Market Data Relay Server is controlled using three operational scripts: &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== start.sh ===&lt;br /&gt;
&lt;br /&gt;
* Exits immediately if the server is already running.&lt;br /&gt;
* Creates a &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory if necessary.&lt;br /&gt;
* Moves any existing &amp;lt;code&amp;gt;srv_*.log&amp;lt;/code&amp;gt; files into &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Starts the &amp;lt;code&amp;gt;MarketDataRelayServer&amp;lt;/code&amp;gt; process in the background.&lt;br /&gt;
* Reads network interfaces from &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; and waits until the server is listening on at least one configured address.&lt;br /&gt;
&lt;br /&gt;
This ensures the server is fully initialized before the script exits.&lt;br /&gt;
&lt;br /&gt;
=== stop.sh ===&lt;br /&gt;
&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGINT&amp;lt;/code&amp;gt; to request a graceful shutdown.&lt;br /&gt;
* Waits for termination using exponential backoff (up to 300 seconds).&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGKILL&amp;lt;/code&amp;gt; if the server fails to stop cleanly.&lt;br /&gt;
* Appends a forced-termination message to the most recent log file (if applicable).&lt;br /&gt;
&lt;br /&gt;
This guarantees consistent shutdown behavior across normal and exceptional conditions.&lt;br /&gt;
&lt;br /&gt;
=== check.sh ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt; script verifies whether the server is currently running by inspecting the PID recorded in &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; and testing whether the associated process exists.&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
Upon startup, older log files are moved into the &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
</feed>