aboutsummaryrefslogtreecommitdiff
path: root/public/using-digitalocean-spaces-object-storage-with-fuse.html
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2023-10-29 14:41:39 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2023-10-29 14:41:39 +0100
commit2836163e54e3b94342113314e70ee564c456c43e (patch)
tree59b82fc69e83cc6d92846a8e9f510b0bb865cf3b /public/using-digitalocean-spaces-object-storage-with-fuse.html
parentd50ea4053ea04abb3a455606d4591a8283af0677 (diff)
downloadmitjafelicijan.com-2836163e54e3b94342113314e70ee564c456c43e.tar.gz
Added public folder to git so it get get deployed on vercel
Diffstat (limited to 'public/using-digitalocean-spaces-object-storage-with-fuse.html')
-rwxr-xr-xpublic/using-digitalocean-spaces-object-storage-with-fuse.html261
1 files changed, 261 insertions, 0 deletions
diff --git a/public/using-digitalocean-spaces-object-storage-with-fuse.html b/public/using-digitalocean-spaces-object-storage-with-fuse.html
new file mode 100755
index 0000000..3c20765
--- /dev/null
+++ b/public/using-digitalocean-spaces-object-storage-with-fuse.html
@@ -0,0 +1,261 @@
1<!doctype html><html lang=en-us><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><link href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL69vf8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv76+/8LBwQkAAAAAAAAAAAAAAAC+vb3/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL+9vf/Bv78JAAAAAAAAAAAAAAAAu7q6/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC7ubr/vr29CAAAAAAAAAAAy8nJAZ6foP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAnqGj/6GipAoAAAAAHLjU/xcXHf/BwsL/I8XY/yPK3v8XGiD/IbjL/yPF2f8XGiD/Fxkf/yLF2f8gnK3/Fxog/62ztv8fwNf/FRcd/x271v8mz93/GRsi/xkXHf8p097/GiIp/xobIv8p0t3/KdPe/xocIv8fYmr/KNPe/xoZH/8aHCL/J87c/xy81/8VFxz/IsPZ/8zS0/8XGiD/Ir/R/yPH2/8XGiD/Fxkf/yPH2/8dd4T/GBog/yPJ3f8jyNr/uru9/xcUGv8cudb/EhITDKi5vRKlvMP/RUpOERwcHRAdOj4QHTk8EBwdHRAdNTgQHTo/EBwcHRAcHB0QSGduEKW4vf+koqQfHzg+EBqz0ewSFRv7EyMr/xq51vsTERb7ExUb+xq41fsau9j7ExUb+xiPp/sZudb7ExUb+xMVG/sZuNX/GKvI/BIUGfMdvdn/IrfL/xcaIP8n1eb/J9Dh/xkcIf8ZGR7/J8/f/xxCSv8ZGyH/J9Dg/ybQ4P8ZHCL/FSQs/yPK3/8UExj/GE1b/ybS5P8ZGB7/Ghwj/ynW5P8p2Ob/Ghwi/yWrtv8p1eH/Ghwi/xocIv8p1uT/J8XT/xkcIv8m1un/Hb7d/xUYH/8hzOr/HtHu/xcaIf8XGB//I8vi/xgxOv8XGSD/I8rg/yPK4P8XGiD/GUFL/yPP6f8SERj/Fhkh/x3A4f8AAAAAJ2f9/ydr//8mZPH/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlYu38J2v//ydo/f8AAAAAAAAAAAd8/fkFqf//Iob8sAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMY39awWr//8FfP3/AAAAAAAAAAAFm/7/SfD//wR+/f8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOB/f9B7v//BaX+/wAAAAAAAAAAQ878SAyZ/v9n1v4KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADu9v8DDJb+/z3N/XgAAAAA3/sAAN/7AADf+wAA3/sAAAAAAAAAAAAAAAAAAN/7AAAAAAAAAAAAAAAAAAAAAAAAj/EAAI/5AACP8QAA3/sAAA==" rel=icon type=image/x-icon><title>Using DigitalOcean Spaces Object Storage with FUSE</title><meta name=description content="Couple of months ago DigitalOcean introduced newproduct calledSpaces whichis Object Storage very similar to Amazon&amp;#39;s S3."><link rel=alternate type=application/rss+xml title="Mitja Felicijan's posts" href=https://mitjafelicijan.com/index.xml><link rel=alternate type=application/rss+xml title="Mitja Felicijan's notes" href=https://mitjafelicijan.com/notes.xml><style>body{padding:1rem;max-width:760px;background:#fff;font-family:sans-serif;line-height:1.35rem;font-size:16px;margin:0 auto}hr{margin-block-start:1.5rem}h1,h2,h3{line-height:initial}h1{font-size:xx-large}footer{margin-block-start:2rem}cap{text-transform:capitalize}table{max-width:100%;width:100%;border-collapse:separate;border-spacing:2px;border:1px solid #000;border-left:1px solid #999;border-top:1px solid #999}blockquote{font-style:italic}table thead{background:#eee}ul.list li{padding:.2em 0}ul{line-height:1.4em}td,th{border:1px solid #000;padding:4px;border-right:1px solid #999;border-bottom:1px solid #999;text-align:left}pre{text-wrap:nowrap;overflow-x:auto;padding:0 1em;border:1px solid #dcdcdc}code{padding:0 3px;font-size:14px;border:0}pre code{line-height:1.3em}pre,code,pre *,code *{font-family:monospace}figure{margin-inline-start:0;margin-inline-end:0}figcaption{text-align:center}figcaption p{margin:.3em 0 0}img,video,audio{max-width:100%}header{display:flex;flex-direction:row;gap:3rem}nav{display:flex;gap:.75rem}nav.main{flex-grow:1}.pstatus-orange{background:gold}.pstatus-green{background:#9acd32}.pstatus-red{background:#cd5c5c}@media only screen and (max-width:600px){body{padding:15px}header{flex-direction:column;gap:1rem}a{word-wrap:break-word}}</style><header><nav class=main itemscope itemtype=http://schema.org/SiteNavigationElement role=toolbar><a href=/>Home</a>
2<a href=https://git.mitjafelicijan.com/ target=_blank>Git</a>
3<a href=https://files.mitjafelicijan.com/ target=_blank>Files</a>
4<a href=/radio.pls target=_blank>Radio</a>
5<a href=/mitjafelicijan.pgp.pub.txt target=_blank>PGP</a>
6<a href=/curriculum-vitae.html>CV</a>
7<a href=/index.xml target=_blank>RSS</a></nav></header><main role=main><article itemtype=http://schema.org/Article><h1 itemtype=headline>Using DigitalOcean Spaces Object Storage with FUSE</h1><p><cap>post</cap>, Jan 16, 2018 on <a href=https://mitjafelicijan.com>Mitja Felicijan's blog</a><div><p>Couple of months ago <a href=https://www.digitalocean.com>DigitalOcean</a> introduced new
8product called
9<a href=https://blog.digitalocean.com/introducing-spaces-object-storage/>Spaces</a> which
10is Object Storage very similar to Amazon's S3. This really peaked my interest,
11because this was something I was missing and even the thought of going over the
12internet for such functionality was in no interest to me. Also in fashion with
13their previous pricing this also is very cheap and pricing page is a no-brainer
14compared to AWS or GCE. <a href=https://www.digitalocean.com/pricing/>Prices are clearly and precisely defined and
15outlined</a>. You must love them for that
16:)<h2 id=initial-requirements>Initial requirements</h2><ul><li>Is it possible to use them as a mounted drive with FUSE? (tl;dr YES)<li>Will the performance degrade over time and over different sizes of objects?
17(tl;dr NO&amp;YES)<li>Can storage be mounted on multiple machines at the same time and be writable?
18(tl;dr YES)</ul><blockquote><p>Let me be clear. This scripts I use are made just for benchmarking and are not
19intended to be used in real-life situations. Besides that, I am looking into
20using this approaches but adding caching service in front of it and then
21dumping everything as an object to storage. This could potentially be some
22interesting post of itself. But in case you would need real-time data without
23eventual consistency please take this scripts as they are: not usable in such
24situations.</blockquote><h2 id=is-it-possible-to-use-them-as-a-mounted-drive-with-fuse>Is it possible to use them as a mounted drive with FUSE?</h2><p>Well, actually they can be used in such manor. Because they are similar to <a href=https://aws.amazon.com/s3/>AWS
25S3</a> many tools are available and you can find many
26articles and <a href="https://stackoverflow.com/search?q=s3+fuse">Stackoverflow items</a>.<p>To make this work you will need DigitalOcean account. If you don't have one you
27will not be able to test this code. But if you have an account then you go and
28<a href="https://cloud.digitalocean.com/droplets/new?size=s-1vcpu-1gb&amp;region=ams3&amp;distro=debian&amp;distroImage=debian-9-x64&amp;options=private_networking,install_agent">create new
29Droplet</a>.
30If you click on this link you will already have preselected Debian 9 with
31smallest VM option.<ul><li>Please be sure to add you SSH key, because we will login to this machine
32remotely.<li>If you change your region please remember which one you choose because we will
33need this information when we try to mount space to our machine.</ul><p>Instuctions on how to use SSH keys and how to setup them are available in
34article <a href=https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-digitalocean-droplets>How To Use SSH Keys with DigitalOcean
35Droplets</a>.<figure><img src=/posts/do-fuse/fuse-droplets.png alt="DigitalOcean Droplets"></figure><p>After we created Droplet it's time to create new Space. This is done by clicking
36on a button <a href=https://cloud.digitalocean.com/spaces/new>Create</a> (right top
37corner) and selecting Spaces. Choose pronounceable <code>Unique name</code> because we
38will use it in examples below. You can either choose Private or Public, it
39doesn't matter in our case. And you can always change that in the future.<p>When you have created new Space we should <a href=https://cloud.digitalocean.com/settings/api/tokens>generate Access
40key</a>. This link will guide
41to the page when you can generate this key. After you create new one, please
42save provided Key and Secret because Secret will not be shown again.<figure><img src=/posts/do-fuse/fuse-spaces.png alt="DigitalOcean Spaces"></figure><p>Now that we have new Space and Access key we should SSH into our machine.<pre tabindex=0 style=background-color:#fff><code><span style=display:flex><span><span style=color:green># replace IP with the ip of your newly created droplet</span>
43</span></span><span style=display:flex><span>ssh root@IP
44</span></span><span style=display:flex><span>
45</span></span><span style=display:flex><span><span style=color:green># this will install utilities for mounting storage objects as FUSE</span>
46</span></span><span style=display:flex><span>apt install s3fs
47</span></span><span style=display:flex><span>
48</span></span><span style=display:flex><span><span style=color:green># we now need to provide credentials (access key we created earlier)</span>
49</span></span><span style=display:flex><span><span style=color:green># replace KEY and SECRET with your own credentials but leave the colon between them</span>
50</span></span><span style=display:flex><span><span style=color:green># we also need to set proper permissions</span>
51</span></span><span style=display:flex><span>echo <span style=color:#a31515>&#34;KEY:SECRET&#34;</span> &gt; .passwd-s3fs
52</span></span><span style=display:flex><span>chmod 600 .passwd-s3fs
53</span></span><span style=display:flex><span>
54</span></span><span style=display:flex><span><span style=color:green># now we mount space to our machine</span>
55</span></span><span style=display:flex><span><span style=color:green># replace UNIQUE-NAME with the name you choose earlier</span>
56</span></span><span style=display:flex><span><span style=color:green># if you choose different region for your space be careful about -ourl option (ams3)</span>
57</span></span><span style=display:flex><span>s3fs UNIQUE-NAME /mnt/ -ourl=https://ams3.digitaloceanspaces.com -ouse_cache=/tmp
58</span></span><span style=display:flex><span>
59</span></span><span style=display:flex><span><span style=color:green># now we try to create a file</span>
60</span></span><span style=display:flex><span><span style=color:green># once you mount it may take a couple of seconds to retrieve data</span>
61</span></span><span style=display:flex><span>echo <span style=color:#a31515>&#34;Hello cruel world&#34;</span> &gt; /mnt/hello.txt
62</span></span></code></pre><p>After all this you can return to your browser and go to <a href=https://cloud.digitalocean.com/spaces>DigitalOcean
63Spaces</a> and click on your created
64space. If file hello.txt is present you have successfully mounted space to your
65machine and wrote data to it.<p>I choose the same region for my Droplet and my Space but you don't have to. You
66can have different regions. What this actually does to performance I don't know.<p>Additional information on FUSE:<ul><li><a href=https://github.com/s3fs-fuse/s3fs-fuse>Github project page for s3fs</a><li><a href=https://en.wikipedia.org/wiki/Filesystem_in_Userspace>FUSE - Filesystem in Userspace</a></ul><h2 id=will-the-performance-degrade-over-time-and-over-different-sizes-of-objects>Will the performance degrade over time and over different sizes of objects?</h2><p>For this task I didn't want to just read and write text files or uploading
67images. I actually wanted to figure out if using something like SQlite is viable
68in this case.<h3 id=measurement-experiment-1-file-copy>Measurement experiment 1: File copy</h3><pre tabindex=0 style=background-color:#fff><code><span style=display:flex><span><span style=color:green># first we create some dummy files at different sizes</span>
69</span></span><span style=display:flex><span>dd <span style=color:#00f>if</span>=/dev/zero of=10KB.dat bs=1024 count=10 <span style=color:green>#10KB</span>
70</span></span><span style=display:flex><span>dd <span style=color:#00f>if</span>=/dev/zero of=100KB.dat bs=1024 count=100 <span style=color:green>#100KB</span>
71</span></span><span style=display:flex><span>dd <span style=color:#00f>if</span>=/dev/zero of=1MB.dat bs=1024 count=1024 <span style=color:green>#1MB</span>
72</span></span><span style=display:flex><span>dd <span style=color:#00f>if</span>=/dev/zero of=10MB.dat bs=1024 count=10240 <span style=color:green>#10MB</span>
73</span></span><span style=display:flex><span>
74</span></span><span style=display:flex><span><span style=color:green># now we set time command to only return real</span>
75</span></span><span style=display:flex><span>TIMEFORMAT=%R
76</span></span><span style=display:flex><span>
77</span></span><span style=display:flex><span><span style=color:green># now lets test it</span>
78</span></span><span style=display:flex><span>(time cp 10KB.dat /mnt/) |&amp; tee -a 10KB.results.txt
79</span></span><span style=display:flex><span>
80</span></span><span style=display:flex><span><span style=color:green># and now we automate</span>
81</span></span><span style=display:flex><span><span style=color:green># this will perform the same operation 100 times</span>
82</span></span><span style=display:flex><span><span style=color:green># this will output results into separated files based on objecty size</span>
83</span></span><span style=display:flex><span>n=0; <span style=color:#00f>while</span> (( n++ &lt; 100 )); <span style=color:#00f>do</span> (time cp 10KB.dat /mnt/10KB.$n.dat) |&amp; tee -a 10KB.results.txt; <span style=color:#00f>done</span>
84</span></span><span style=display:flex><span>n=0; <span style=color:#00f>while</span> (( n++ &lt; 100 )); <span style=color:#00f>do</span> (time cp 100KB.dat /mnt/100KB.$n.dat) |&amp; tee -a 100KB.results.txt; <span style=color:#00f>done</span>
85</span></span><span style=display:flex><span>n=0; <span style=color:#00f>while</span> (( n++ &lt; 100 )); <span style=color:#00f>do</span> (time cp 1MB.dat /mnt/1MB.$n.dat) |&amp; tee -a 1MB.results.txt; <span style=color:#00f>done</span>
86</span></span><span style=display:flex><span>n=0; <span style=color:#00f>while</span> (( n++ &lt; 100 )); <span style=color:#00f>do</span> (time cp 10MB.dat /mnt/10MB.$n.dat) |&amp; tee -a 10MB.results.txt; <span style=color:#00f>done</span>
87</span></span></code></pre><p>Files of size 100MB were not successfully transferred and ended up displaying
88error (cp: failed to close '/mnt/100MB.1.dat': Operation not permitted).<p>As I suspected, object size is not really that important. Sadly I don't have the
89time to test performance over periods of time. But if some of you would do it
90please send me your data. I would be interested in seeing results.<p><strong>Here are plotted results</strong><p>You can download <a href=/posts/do-fuse/copy-benchmarks.tsv>raw result here</a>.
91Measurements are in seconds.</p><script src=//cdn.plot.ly/plotly-latest.min.js></script><div id=copy-benchmarks></div><script>
92(function(){
93 var request = new XMLHttpRequest();
94 request.open("GET", "/posts/do-fuse/copy-benchmarks.tsv", true);
95 request.onload = function() {
96 if (request.status >= 200 && request.status < 400) {
97 var payload = request.responseText.trim();
98 var tsv = payload.split("\n");
99 for (var i=0; i<tsv.length; i++) { tsv[i] = tsv[i].split("\t"); }
100 var traces = [];
101 var headers = tsv[0];
102 tsv.shift();
103 Array.prototype.forEach.call(headers, function(el, idx) {
104 var x = [];
105 var y = [];
106 for (var j=0; j<tsv.length; j++) {
107 x.push(j);
108 y.push(parseFloat(tsv[j][idx].replace(",", ".")));
109 }
110 traces.push({ x: x, y: y, type: "scatter", name: el, line: { width: 1, shape: "spline" } });
111 });
112 var copy = Plotly.newPlot("copy-benchmarks", traces, { legend: {"orientation": "h"}, height: 400, margin: { l: 40, r: 0, b: 20, t: 30, pad: 0 }, yaxis: { title: "execution time in seconds", titlefont: { size: 12 } }, xaxis: { title: "fn(i)", titlefont: { size: 12 } } });
113 } else { }
114 };
115 request.onerror = function() { };
116 request.send(null);
117})();
118</script><p>As far as these tests show, performance is quite stable and can be predicted
119which is fantastic. But this is a small test and spans only over couple of
120hours. So you should not completely trust them.<h3 id=measurement-experiment-2-sqlite-performanse>Measurement experiment 2: SQLite performanse</h3><p>I was unable to use database file directly from mounted drive so this is a no-go
121as I suspected. So I executed code below on a local disk just to get some
122benchmarks. I inserted 1000 records with DROPTABLE, CREATETABLE, INSERTMANY,
123FETCHALL, COMMIT for 1000 times to generate statistics. As you can see
124performance of SQLite is quite amazing. You could then potentially just copy
125file to mounted drive and be done with it.<pre tabindex=0 style=background-color:#fff><code><span style=display:flex><span><span style=color:#00f>import</span> time
126</span></span><span style=display:flex><span><span style=color:#00f>import</span> sqlite3
127</span></span><span style=display:flex><span><span style=color:#00f>import</span> sys
128</span></span><span style=display:flex><span>
129</span></span><span style=display:flex><span><span style=color:#00f>if</span> len(sys.argv) &lt; 3:
130</span></span><span style=display:flex><span> print(<span style=color:#a31515>&#34;usage: python sqlite-benchmark.py DB_PATH NUM_RECORDS REPEAT&#34;</span>)
131</span></span><span style=display:flex><span> exit()
132</span></span><span style=display:flex><span>
133</span></span><span style=display:flex><span><span style=color:#00f>def</span> data_iter(x):
134</span></span><span style=display:flex><span> <span style=color:#00f>for</span> i <span style=color:#00f>in</span> range(x):
135</span></span><span style=display:flex><span> <span style=color:#00f>yield</span> <span style=color:#a31515>&#34;m&#34;</span> + str(i), <span style=color:#a31515>&#34;f&#34;</span> + str(i*i)
136</span></span><span style=display:flex><span>
137</span></span><span style=display:flex><span>header_line = <span style=color:#a31515>&#34;</span><span style=color:#a31515>%s</span><span style=color:#a31515>\t</span><span style=color:#a31515>%s</span><span style=color:#a31515>\t</span><span style=color:#a31515>%s</span><span style=color:#a31515>\t</span><span style=color:#a31515>%s</span><span style=color:#a31515>\t</span><span style=color:#a31515>%s</span><span style=color:#a31515>\n</span><span style=color:#a31515>&#34;</span> % (<span style=color:#a31515>&#34;DROPTABLE&#34;</span>, <span style=color:#a31515>&#34;CREATETABLE&#34;</span>, <span style=color:#a31515>&#34;INSERTMANY&#34;</span>, <span style=color:#a31515>&#34;FETCHALL&#34;</span>, <span style=color:#a31515>&#34;COMMIT&#34;</span>)
138</span></span><span style=display:flex><span><span style=color:#00f>with</span> open(<span style=color:#a31515>&#34;sqlite-benchmarks.tsv&#34;</span>, <span style=color:#a31515>&#34;w&#34;</span>) <span style=color:#00f>as</span> fp:
139</span></span><span style=display:flex><span> fp.write(header_line)
140</span></span><span style=display:flex><span>
141</span></span><span style=display:flex><span>start_time = time.time()
142</span></span><span style=display:flex><span>conn = sqlite3.connect(sys.argv[1])
143</span></span><span style=display:flex><span>c = conn.cursor()
144</span></span><span style=display:flex><span>end_time = time.time()
145</span></span><span style=display:flex><span>result_time = CONNECT = end_time - start_time
146</span></span><span style=display:flex><span>print(<span style=color:#a31515>&#34;CONNECT: </span><span style=color:#a31515>%g</span><span style=color:#a31515> seconds&#34;</span> % (result_time))
147</span></span><span style=display:flex><span>
148</span></span><span style=display:flex><span>start_time = time.time()
149</span></span><span style=display:flex><span>c.execute(<span style=color:#a31515>&#34;PRAGMA journal_mode=WAL&#34;</span>)
150</span></span><span style=display:flex><span>c.execute(<span style=color:#a31515>&#34;PRAGMA temp_store=MEMORY&#34;</span>)
151</span></span><span style=display:flex><span>c.execute(<span style=color:#a31515>&#34;PRAGMA synchronous=OFF&#34;</span>)
152</span></span><span style=display:flex><span>result_time = PRAGMA = end_time - start_time
153</span></span><span style=display:flex><span>print(<span style=color:#a31515>&#34;PRAGMA: </span><span style=color:#a31515>%g</span><span style=color:#a31515> seconds&#34;</span> % (result_time))
154</span></span><span style=display:flex><span>
155</span></span><span style=display:flex><span><span style=color:#00f>for</span> i <span style=color:#00f>in</span> range(int(sys.argv[3])):
156</span></span><span style=display:flex><span> print(<span style=color:#a31515>&#34;#</span><span style=color:#a31515>%i</span><span style=color:#a31515>&#34;</span> % (i))
157</span></span><span style=display:flex><span>
158</span></span><span style=display:flex><span> start_time = time.time()
159</span></span><span style=display:flex><span> c.execute(<span style=color:#a31515>&#34;drop table if exists test&#34;</span>)
160</span></span><span style=display:flex><span> end_time = time.time()
161</span></span><span style=display:flex><span> result_time = DROPTABLE = end_time - start_time
162</span></span><span style=display:flex><span> print(<span style=color:#a31515>&#34;DROPTABLE: </span><span style=color:#a31515>%g</span><span style=color:#a31515> seconds&#34;</span> % (result_time))
163</span></span><span style=display:flex><span>
164</span></span><span style=display:flex><span> start_time = time.time()
165</span></span><span style=display:flex><span> c.execute(<span style=color:#a31515>&#34;create table if not exists test(a,b)&#34;</span>)
166</span></span><span style=display:flex><span> end_time = time.time()
167</span></span><span style=display:flex><span> result_time = CREATETABLE = end_time - start_time
168</span></span><span style=display:flex><span> print(<span style=color:#a31515>&#34;CREATETABLE: </span><span style=color:#a31515>%g</span><span style=color:#a31515> seconds&#34;</span> % (result_time))
169</span></span><span style=display:flex><span>
170</span></span><span style=display:flex><span> start_time = time.time()
171</span></span><span style=display:flex><span> c.executemany(<span style=color:#a31515>&#34;INSERT INTO test VALUES (?, ?)&#34;</span>, data_iter(int(sys.argv[2])))
172</span></span><span style=display:flex><span> end_time = time.time()
173</span></span><span style=display:flex><span> result_time = INSERTMANY = end_time - start_time
174</span></span><span style=display:flex><span> print(<span style=color:#a31515>&#34;INSERTMANY: </span><span style=color:#a31515>%g</span><span style=color:#a31515> seconds&#34;</span> % (result_time))
175</span></span><span style=display:flex><span>
176</span></span><span style=display:flex><span> start_time = time.time()
177</span></span><span style=display:flex><span> c.execute(<span style=color:#a31515>&#34;select count(*) from test&#34;</span>)
178</span></span><span style=display:flex><span> res = c.fetchall()
179</span></span><span style=display:flex><span> end_time = time.time()
180</span></span><span style=display:flex><span> result_time = FETCHALL = end_time - start_time
181</span></span><span style=display:flex><span> print(<span style=color:#a31515>&#34;FETCHALL: </span><span style=color:#a31515>%g</span><span style=color:#a31515> seconds&#34;</span> % (result_time))
182</span></span><span style=display:flex><span>
183</span></span><span style=display:flex><span> start_time = time.time()
184</span></span><span style=display:flex><span> conn.commit()
185</span></span><span style=display:flex><span> end_time = time.time()
186</span></span><span style=display:flex><span> result_time = COMMIT = end_time - start_time
187</span></span><span style=display:flex><span> print(<span style=color:#a31515>&#34;COMMIT: </span><span style=color:#a31515>%g</span><span style=color:#a31515> seconds&#34;</span> % (result_time))
188</span></span><span style=display:flex><span>
189</span></span><span style=display:flex><span> print
190</span></span><span style=display:flex><span> log_line = <span style=color:#a31515>&#34;</span><span style=color:#a31515>%f</span><span style=color:#a31515>\t</span><span style=color:#a31515>%f</span><span style=color:#a31515>\t</span><span style=color:#a31515>%f</span><span style=color:#a31515>\t</span><span style=color:#a31515>%f</span><span style=color:#a31515>\t</span><span style=color:#a31515>%f</span><span style=color:#a31515>\n</span><span style=color:#a31515>&#34;</span> % (DROPTABLE, CREATETABLE, INSERTMANY, FETCHALL, COMMIT)
191</span></span><span style=display:flex><span> <span style=color:#00f>with</span> open(<span style=color:#a31515>&#34;sqlite-benchmarks.tsv&#34;</span>, <span style=color:#a31515>&#34;a&#34;</span>) <span style=color:#00f>as</span> fp:
192</span></span><span style=display:flex><span> fp.write(log_line)
193</span></span><span style=display:flex><span>
194</span></span><span style=display:flex><span>start_time = time.time()
195</span></span><span style=display:flex><span>conn.close()
196</span></span><span style=display:flex><span>end_time = time.time()
197</span></span><span style=display:flex><span>result_time = CLOSE = end_time - start_time
198</span></span><span style=display:flex><span>print(<span style=color:#a31515>&#34;CLOSE: </span><span style=color:#a31515>%g</span><span style=color:#a31515> seconds&#34;</span> % (result_time))
199</span></span></code></pre><p>You can download <a href=/posts/do-fuse/sqlite-benchmarks.tsv>raw result here</a>. And
200again, these results are done on a local block storage and do not represent
201capabilities of object storage. With my current approach and state of the test
202code these can not be done. I would need to make Python code much more robust
203and check locking etc.<div id=sqlite-benchmarks></div><script>
204(function(){
205 var request = new XMLHttpRequest();
206 request.open("GET", "/posts/do-fuse/sqlite-benchmarks.tsv", true);
207 request.onload = function() {
208 if (request.status >= 200 && request.status < 400) {
209 var payload = request.responseText.trim();
210 var tsv = payload.split("\n");
211 for (var i=0; i<tsv.length; i++) { tsv[i] = tsv[i].split("\t"); }
212 var traces = [];
213 var headers = tsv[0];
214 tsv.shift();
215 Array.prototype.forEach.call(headers, function(el, idx) {
216 var x = [];
217 var y = [];
218 for (var j=0; j<tsv.length; j++) {
219 x.push(j);
220 y.push(parseFloat(tsv[j][idx].replace(",", ".")));
221 }
222 traces.push({ x: x, y: y, type: "scatter", name: el, line: { width: 1, shape: "spline" } });
223 });
224 var sqlite = Plotly.newPlot("sqlite-benchmarks", traces, { legend: {"orientation": "h"}, height: 400, margin: { l: 50, r: 0, b: 20, t: 30, pad: 0 }, yaxis: { title: "execution time in seconds", titlefont: { size: 12 } } });
225 } else { }
226 };
227 request.onerror = function() { };
228 request.send(null);
229})();
230</script><h2 id=can-storage-be-mounted-on-multiple-machines-at-the-same-time-and-be-writable>Can storage be mounted on multiple machines at the same time and be writable?</h2><p>Well, this one didn't take long to test. And the answer is <strong>YES</strong>. I mounted
231space on both machines and measured same performance on both machines. But
232because file is downloaded before write and then uploaded on complete there
233could potentially be problems is another process is trying to access the same
234file.<h2 id=observations-and-conslusion>Observations and conslusion</h2><p>Using Spaces in this way makes it easier to access and manage files. But besides
235that you would need to write additional code to make this one play nice with you
236applications.<p>Nevertheless, this was extremely simple to setup and use and this is just
237another excellent product in DigitalOcean product line. I found this exercise
238very valuable and am thinking about implementing some sort of mechanism for
239SQLite, so data can be stored on Spaces and accessed by many VM's. For a project
240where data doesn't need to be accessible in real-time and can have couple of
241minutes old data this would be very interesting. If any of you find this
242proposal interesting please write in a comment box below or shoot me an email
243and I will keep you posted.</div></article></main><section><hr><h2>Posts from blogs I follow around the net</h2><ul><li><a href=https://chotrin.org/writing/2023-10-20.html target=_blank rel=noopener>OpenBSD upgrade and fall things.</a><div>Been AFK for a bit. It's autumn and I upgraded this server to OpenBSD 7.4! — <a href=https://chotrin.org>chötrin's wiki.</a><li><a href=https://mirzapandzo.com/next-image-url-parameter-is-valid-but-upstream-response-is-invalid target=_blank rel=noopener>Next/Image "url" parameter is valid but upstream response is invalid</a><div>Getting "url" parameter is valid but upstream response is invalid error with Next/Image on WSL2 — <a href=https://mirzapandzo.com/>Mirza Pandzo's Blog</a><li><a href=https://drewdevault.com/2023/10/13/Going-off-script.html target=_blank rel=noopener>Going off-script</a><div>There is a phenomenon in society which I find quite bizarre. Upon our entry to
244this mortal coil, we are endowed with self-awareness, agency, and free will.
245Each of th… — <a href=https://drewdevault.com>Drew DeVault's blog</a><li><a href=https://solar.lowtechmagazine.com/2023/10/workshop-in-rotterdam-how-to-build-a-bike-generator/ target=_blank rel=noopener>Workshop in Rotterdam: How to Build a Bike Generator</a><div>Afbeelding: Low-tech Magazine workshop in Rotterdam, the Netherlands. Poster: Marie Verdeil. Image: Sara Vercauteren
246The workshop takes place on behalf of the “Hou… — <a href=https://solar.lowtechmagazine.com/posts/>LOW←TECH MAGAZINE English</a><li><a href="http://offbeatpursuit.com:80/blog/?id=24" target=_blank rel=noopener>Printf debugging</a><div>tags:
247plan9
248There’s no shame in that. Yes, there is documentation, code to be
249read, and debuggers to be used. But sometimes you just need to “see”
250what is happening.
251So… — <a href=http://offbeatpursuit.com:80/blog/>WLOG - blog</a><li><a href=https://neil.computer/notes/chart-of-accounts-for-startups-and-saas-companies/ target=_blank rel=noopener>Chart of Accounts for Startups and SaaS Companies</a><div>Accounting is fundamental to starting a business. You need to have a basic understanding of accounting principles and essential bookkeeping. I had to learn it. Ther… — <a href=https://neil.computer/>Neil Panchal</a><li><a href=https://journal.valeriansaliou.name/deploy-a-nomad-cluster-on-alpine-linux-with-vultr/ target=_blank rel=noopener>Deploy a Nomad Cluster on Alpine Linux with Vultr</a><div>After spending countless hours trying to understand how to deploy my apps on Kubernetes for the first time to host Mirage, an AI API service that I run, I ended up … — <a href=https://journal.valeriansaliou.name/>Valerian Saliou</a><li><a href=https://jcs.org/2023/10/17/wikipedia target=_blank rel=noopener>Wikipedia Reader 1.0 Released</a><div>Wikipedia Reader
2521.0 has been released:
253wikipedia-1.0.sit
254(StuffIt 3 archive, includes
255source code
256and THINK C 5 project file)
257SHA256: 360e12d064f6579695f1e627ce34cb2f0… — <a href=https://jcs.org/>joshua stein</a></ul><p><a href=https://git.sr.ht/~sircmpwn/openring>Generated with openring.</a></section><footer><hr><p><big><strong>Want to comment or have something to add?</strong></big><p>You can write me an email
258at <a href=mailto:m@mitjafelicijan.com>m@mitjafelicijan.com</a> or
259catch up with me <a href=https://telegram.me/mitjafelicijan target=_blank>on Telegram</a>.<hr><p>This website does not track you. Content is made available under
260the <a href=https://creativecommons.org/licenses/by/4.0/ target=_blank rel=noreferrer>CC BY 4.0 license</a> unless specified
261otherwise. Blog is also available as <a href=/index.xml target=_blank>RSS feed</a>.</footer> \ No newline at end of file