{"data":{"markdownRemark":{"html":"<p>This page explains how to setup and use the Simudyne SDK  to distribute a single simulation using Spark and Akka.\n<a href=\"https://spark.apache.org/\">Spark</a> is used as a cluster management tool while <a href=\"https://akka.io/\">Akka</a> manages all the communication logic.</p>\n<h2 id=\"distributed-graph-backend\"><a href=\"#distributed-graph-backend\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Distributed Graph Backend</h2>\n<p>The distributed graph backend allows you to run large graphs on a cluster of machines.\nRunning a distributed graph simulation depends on the <code class=\"language-text\">core-graph-distributed</code> package which needs to be imported in your project:</p>\n<p class=\"code-header\">pom.xml</p>\n<div class=\"gatsby-highlight\" data-language=\"xml\"><pre class=\"language-xml\"><code class=\"language-xml\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>dependency</span><span class=\"token punctuation\">></span></span>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>groupId</span><span class=\"token punctuation\">></span></span>simudyne<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>groupId</span><span class=\"token punctuation\">></span></span>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>artifactId</span><span class=\"token punctuation\">></span></span>simudyne-core-graph-distributed_2.11<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>artifactId</span><span class=\"token punctuation\">></span></span>\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>version</span><span class=\"token punctuation\">></span></span>${simudyne.version}<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>version</span><span class=\"token punctuation\">></span></span>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>dependency</span><span class=\"token punctuation\">></span></span></code></pre></div>\n<p>Simudyne has two implementations of the distributed graph. One runs locally using subprocesses and can be used for testing purposes. This implementation does <strong>NOT</strong> require Spark.\nThe other implementation distributes the load using Spark and thus needs to be provided with a working Spark cluster.</p>\n<h2 id=\"testing-model-in-distributed-environment\"><a href=\"#testing-model-in-distributed-environment\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Testing model in distributed environment</h2>\n<p>Aimed towards model developers, we have included a way of running distributed graph using subprocesses,\nwithout need for spark, in order to establish model's compatibility and distributed-graph readiness.</p>\n<h2 id=\"properties\"><a href=\"#properties\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Properties</h2>\n<p>Both implementations share the same main properties.</p>\n<p>You need to configure the properties related to core-graph-distributed.\nYou have two possibilities to configure them:</p>\n<ul>\n<li>modify the properties in the <code class=\"language-text\">simudyneSDK.properties</code> file (enforced for local implementation)</li>\n<li>set configuration parameters as command parameters when using <code class=\"language-text\">spark-submit</code> command (only available using the Spark implementation)</li>\n</ul>\n<p>Some properties are already listed with default values in <code class=\"language-text\">simudyneSDK.properties</code>:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">### CORE ABM distributed (experimental)\n# core.graph.experimental.timeouts.base=240\ncore.graph.experimental.clusterSize=3</code></pre></div>\n<ul>\n<li>\n<p><strong>core.graph.experimental.timeouts.base</strong>: due to the distributed nature of the environment, the distributed graph needs a setting to be able to establish when the\ncommunication between nodes should be considered <em>slow</em> or <em>failing</em>. Observing that the steps take a similar time to the value this is set to, is a likely indicator of potential failure.</p>\n</li>\n<li>\n<p><strong>core.graph.experimental.clusterSize</strong>: Controls how many nodes are required in order for the graph to be considered ready for work.\nWhen using the local implementation, controls the number of spawned subprocesses.\nWhen using the Spark implementation, controls the number of partitions. Remember to set <code class=\"language-text\">--executor-cores</code> and <code class=\"language-text\">--num-executors</code> during <code class=\"language-text\">spark-submit</code>.</p>\n</li>\n</ul>\n<h2 id=\"limitations\"><a href=\"#limitations\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Limitations</h2>\n<div class=\"ui segment warning message\">\n    <p>The Distributed graph comes with limitations, most notable being:<br />\n    <li> no support for Immutable Schema, please set <b>feature.immutable-schema=false</b></li>\n    <li> no support for dynamic agent creation/stopping</li>\n    <li> no support for SystemMessages </li>\n    <p>You also might want to disable the health check for models by setting <b>nexus-server.health-check</b> to false in order to avoid their distribution.</p>\n</div>\n<h2 id=\"local-implementation\"><a href=\"#local-implementation\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Local Implementation</h2>\n<p>To test your model running on Distributed Graph, add the following lines to your properties file:</p>\n<p class=\"code-header\">simudyneSDK.properties</p>\n<div class=\"gatsby-highlight\" data-language=\"scala\"><pre class=\"language-scala\"><code class=\"language-scala\">core<span class=\"token operator\">-</span>abm<span class=\"token punctuation\">.</span>backend<span class=\"token operator\">-</span>implementation<span class=\"token operator\">=</span>simudyne<span class=\"token punctuation\">.</span>core<span class=\"token punctuation\">.</span>graph<span class=\"token punctuation\">.</span>experimental<span class=\"token punctuation\">.</span>dig<span class=\"token punctuation\">.</span>treelike<span class=\"token punctuation\">.</span>backend<span class=\"token punctuation\">.</span>SubprocessBackend\nfeature<span class=\"token punctuation\">.</span>immutable<span class=\"token operator\">-</span>schema<span class=\"token operator\">=</span><span class=\"token boolean\">false</span></code></pre></div>\n<p>You can then start the server and control the simulation through the Console or the REST API without further configuration.</p>\n<h2 id=\"cluster-implementation\"><a href=\"#cluster-implementation\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Cluster Implementation</h2>\n<p>To let Spark manage nodes of the Distributed Graph implementation, add the following:</p>\n<p class=\"code-header\">simudyneSDK.properties</p>\n<div class=\"gatsby-highlight\" data-language=\"scala\"><pre class=\"language-scala\"><code class=\"language-scala\">core<span class=\"token operator\">-</span>abm<span class=\"token punctuation\">.</span>backend<span class=\"token operator\">-</span>implementation<span class=\"token operator\">=</span>simudyne<span class=\"token punctuation\">.</span>core<span class=\"token punctuation\">.</span>graph<span class=\"token punctuation\">.</span>experimental<span class=\"token punctuation\">.</span>dig<span class=\"token punctuation\">.</span>treelike<span class=\"token punctuation\">.</span>backend<span class=\"token punctuation\">.</span>spark<span class=\"token punctuation\">.</span>ClusterBackend\ncore<span class=\"token punctuation\">.</span>graph<span class=\"token punctuation\">.</span>experimental<span class=\"token punctuation\">.</span>distributed<span class=\"token punctuation\">.</span>master<span class=\"token operator\">-</span>url<span class=\"token operator\">=</span>local<span class=\"token punctuation\">[</span><span class=\"token operator\">*</span><span class=\"token punctuation\">]</span>\ncore<span class=\"token punctuation\">.</span>graph<span class=\"token punctuation\">.</span>experimental<span class=\"token punctuation\">.</span>distributed<span class=\"token punctuation\">.</span>log<span class=\"token operator\">-</span>level<span class=\"token operator\">=</span>WARN\nfeature<span class=\"token punctuation\">.</span>immutable<span class=\"token operator\">-</span>schema<span class=\"token operator\">=</span><span class=\"token boolean\">false</span></code></pre></div>\n<p>Please be aware that properties set in <code class=\"language-text\">simudyneSDK.properties</code> file takes precedence over options passed to <code class=\"language-text\">spark-submit</code>.</p>\n<p>You can then submit your job using <code class=\"language-text\">spark-submit</code>. Here is an example:</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">spark-submit --class Main --master yarn  --deploy-mode client --files simudyneSDK.properties,licenseKey hdfs://path/name-of-the-fat-jar.jar</code></pre></div>\n<p>This command will run the <strong>main</strong> function of the class <strong>Main</strong> and distribute it on Spark. You can then access the console through the config parameters <code class=\"language-text\">nexus-server.hostname</code> and <code class=\"language-text\">nexus-server.port</code>.\nThey default to <code class=\"language-text\">localhost</code> and <code class=\"language-text\">8080</code>. You can also interact with the server through the <a href=\":version/rest_api/rest_api\">REST API</a></p>\n<p><strong>spark-submit</strong> allows you to configure Spark. You need to choose a configuration that best suits your cluster.\nTo learn more about Spark configuration, refer to the <a href=\"https://spark.apache.org/docs/latest/submitting-applications.html\">official documentation</a>.</p>\n<p>Some <a href=\"http://blog.cloudera.com/blog/2015/03/how-to-tune-your-apache-spark-jobs-part-2/\">useful resources</a> can be found on Cloudera's website.</p>","headings":[{"value":"Distributed Graph Backend","depth":2},{"value":"Testing model in distributed environment","depth":2},{"value":"Properties","depth":2},{"value":"Limitations","depth":2},{"value":"Local Implementation","depth":2},{"value":"Cluster Implementation","depth":2}],"frontmatter":{"title":"Akka Distributed Graph","toc":null,"experimental":true}},"site":{"siteMetadata":{"title":"Simudyne Docs","latestVersion":"2.6"}}},"pageContext":{"absolutePath":"/home/vsts/work/1/s/content/2.5/reference/experimental/akka.md","versioned":true,"version":"2.5","kind":"reference","pagePath":"/reference/experimental/akka","chronology":{"prev":{"name":"Experimental","path":"/reference/experimental"},"next":{"name":"Auto-compiler","path":"/reference/experimental/auto-compiler"}},"lastUpdated":"2026-04-21T13:56:54.861Z"}}