aboutsummaryrefslogtreecommitdiff
path: root/content/posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2023-05-26 00:40:40 +0200
committerMitja Felicijan <mitja.felicijan@gmail.com>2023-05-26 00:40:40 +0200
commit43b0708769eb61392050045b881f8e6ba39c5b66 (patch)
tree3939579a13b8325325d5ebb8e05324a41ed78a6d /content/posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md
parent49e7e7d555a6cd9810d81561fa3e98e3d64502be (diff)
downloadmitjafelicijan.com-43b0708769eb61392050045b881f8e6ba39c5b66.tar.gz
Massive update to posts, archetypes
Added a archetypes for creating notes and posts so it auto-populates fields. Fixed existing posts so they align with the rule of 80 columns now.
Diffstat (limited to 'content/posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md')
-rw-r--r--content/posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md117
1 files changed, 92 insertions, 25 deletions
diff --git a/content/posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md b/content/posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md
index 75f7799..bfc77ee 100644
--- a/content/posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md
+++ b/content/posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md
@@ -1,36 +1,67 @@
1--- 1---
2title: Using DigitalOcean Spaces Object Storage with FUSE 2title: Using DigitalOcean Spaces Object Storage with FUSE
3url: using-digitalocean-spaces-object-storage-with-fuse.html 3url: using-digitalocean-spaces-object-storage-with-fuse.html
4date: 2018-01-16 4date: 2018-01-16T12:00:00+02:00
5draft: false 5draft: false
6--- 6---
7 7
8Couple of months ago [DigitalOcean](https://www.digitalocean.com) introduced new product called [Spaces](https://blog.digitalocean.com/introducing-spaces-object-storage/) which is Object Storage very similar to Amazon's S3. This really peaked my interest, because this was something I was missing and even the thought of going over the internet for such functionality was in no interest to me. Also in fashion with their previous pricing this also is very cheap and pricing page is a no-brainer compared to AWS or GCE. [Prices are clearly and precisely defined and outlined](https://www.digitalocean.com/pricing/). You must love them for that :) 8Couple of months ago [DigitalOcean](https://www.digitalocean.com) introduced
9new product called [Spaces](https://blog.digitalocean.com/introducing-spaces-object-storage/)
10which is Object Storage very similar to Amazon's S3. This really peaked my
11interest, because this was something I was missing and even the thought of
12going over the internet for such functionality was in no interest to me. Also
13in fashion with their previous pricing this also is very cheap and pricing
14page is a no-brainer compared to AWS or GCE. [Prices are clearly and precisely defined and outlined](https://www.digitalocean.com/pricing/).
15You must love them for that :)
9 16
10## Initial requirements 17## Initial requirements
11 18
12* Is it possible to use them as a mounted drive with FUSE? (tl;dr YES) 19* Is it possible to use them as a mounted drive with FUSE? (tl;dr YES)
13* Will the performance degrade over time and over different sizes of objects? (tl;dr NO&YES) 20* Will the performance degrade over time and over different sizes of objects?
14* Can storage be mounted on multiple machines at the same time and be writable? (tl;dr YES) 21 (tl;dr NO&YES)
15 22* Can storage be mounted on multiple machines at the same time and be writable?
16> Let me be clear. This scripts I use are made just for benchmarking and are not intended to be used in real-life situations. Besides that, I am looking into using this approaches but adding caching service in front of it and then dumping everything as an object to storage. This could potentially be some interesting post of itself. But in case you would need real-time data without eventual consistency please take this scripts as they are: not usable in such situations. 23 (tl;dr YES)
24
25> Let me be clear. This scripts I use are made just for benchmarking and are
26> not intended to be used in real-life situations. Besides that, I am looking
27> into using this approaches but adding caching service in front of it and then
28> dumping everything as an object to storage. This could potentially be some
29> interesting post of itself. But in case you would need real-time data without
30> eventual consistency please take this scripts as they are: not usable in such
31> situations.
17 32
18## Is it possible to use them as a mounted drive with FUSE? 33## Is it possible to use them as a mounted drive with FUSE?
19 34
20Well, actually they can be used in such manor. Because they are similar to [AWS S3](https://aws.amazon.com/s3/) many tools are available and you can find many articles and [Stackoverflow items](https://stackoverflow.com/search?q=s3+fuse). 35Well, actually they can be used in such manor. Because they are similar to
36[AWS S3](https://aws.amazon.com/s3/) many tools are available and you can find
37many articles and [Stackoverflow items](https://stackoverflow.com/search?q=s3+fuse).
21 38
22To make this work you will need DigitalOcean account. If you don't have one you will not be able to test this code. But if you have an account then you go and [create new Droplet](https://cloud.digitalocean.com/droplets/new?size=s-1vcpu-1gb&region=ams3&distro=debian&distroImage=debian-9-x64&options=private_networking,install_agent). If you click on this link you will already have preselected Debian 9 with smallest VM option. 39To make this work you will need DigitalOcean account. If you don't have one you
40will not be able to test this code. But if you have an account then you go and
41[create new Droplet](https://cloud.digitalocean.com/droplets/new?size=s-1vcpu-1gb&region=ams3&distro=debian&distroImage=debian-9-x64&options=private_networking,install_agent).
42If you click on this link you will already have preselected Debian 9 with
43smallest VM option.
23 44
24* Please be sure to add you SSH key, because we will login to this machine remotely. 45* Please be sure to add you SSH key, because we will login to this machine
25* If you change your region please remember which one you choose because we will need this information when we try to mount space to our machine. 46 remotely.
47* If you change your region please remember which one you choose because we
48 will need this information when we try to mount space to our machine.
26 49
27Instuctions on how to use SSH keys and how to setup them are available in article [How To Use SSH Keys with DigitalOcean Droplets](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-digitalocean-droplets). 50Instuctions on how to use SSH keys and how to setup them are available in article
51[How To Use SSH Keys with DigitalOcean Droplets](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-digitalocean-droplets).
28 52
29![DigitalOcean Droplets](/assets/do-fuse/fuse-droplets.png) 53![DigitalOcean Droplets](/assets/do-fuse/fuse-droplets.png)
30 54
31After we created Droplet it's time to create new Space. This is done by clicking on a button [Create](https://cloud.digitalocean.com/spaces/new) (right top corner) and selecting Spaces. Choose pronounceable ```Unique name``` because we will use it in examples below. You can either choose Private or Public, it doesn't matter in our case. And you can always change that in the future. 55After we created Droplet it's time to create new Space. This is done by clicking
56on a button [Create](https://cloud.digitalocean.com/spaces/new) (right top
57corner) and selecting Spaces. Choose pronounceable ```Unique name``` because we
58will use it in examples below. You can either choose Private or Public, it
59doesn't matter in our case. And you can always change that in the future.
32 60
33When you have created new Space we should [generate Access key](https://cloud.digitalocean.com/settings/api/tokens). This link will guide to the page when you can generate this key. After you create new one, please save provided Key and Secret because Secret will not be shown again. 61When you have created new Space we should [generate Access key](https://cloud.digitalocean.com/settings/api/tokens).
62This link will guide to the page when you can generate this key. After you
63create new one, please save provided Key and Secret because Secret will not
64be shown again.
34 65
35![DigitalOcean Spaces](/assets/do-fuse/fuse-spaces.png) 66![DigitalOcean Spaces](/assets/do-fuse/fuse-spaces.png)
36 67
@@ -59,9 +90,14 @@ s3fs UNIQUE-NAME /mnt/ -ourl=https://ams3.digitaloceanspaces.com -ouse_cache=/tm
59echo "Hello cruel world" > /mnt/hello.txt 90echo "Hello cruel world" > /mnt/hello.txt
60``` 91```
61 92
62After all this you can return to your browser and go to [DigitalOcean Spaces](https://cloud.digitalocean.com/spaces) and click on your created space. If file hello.txt is present you have successfully mounted space to your machine and wrote data to it. 93After all this you can return to your browser and go to
94[DigitalOcean Spaces](https://cloud.digitalocean.com/spaces) and click on your
95created space. If file hello.txt is present you have successfully mounted
96space to your machine and wrote data to it.
63 97
64I choose the same region for my Droplet and my Space but you don't have to. You can have different regions. What this actually does to performance I don't know. 98I choose the same region for my Droplet and my Space but you don't have to.
99You can have different regions. What this actually does to performance I
100don't know.
65 101
66Additional information on FUSE: 102Additional information on FUSE:
67 103
@@ -70,7 +106,9 @@ Additional information on FUSE:
70 106
71## Will the performance degrade over time and over different sizes of objects? 107## Will the performance degrade over time and over different sizes of objects?
72 108
73For this task I didn't want to just read and write text files or uploading images. I actually wanted to figure out if using something like SQlite is viable in this case. 109For this task I didn't want to just read and write text files or uploading
110images. I actually wanted to figure out if using something like SQlite is
111viable in this case.
74 112
75### Measurement experiment 1: File copy 113### Measurement experiment 1: File copy
76 114
@@ -96,13 +134,17 @@ n=0; while (( n++ < 100 )); do (time cp 1MB.dat /mnt/1MB.$n.dat) |& tee -a 1MB.r
96n=0; while (( n++ < 100 )); do (time cp 10MB.dat /mnt/10MB.$n.dat) |& tee -a 10MB.results.txt; done 134n=0; while (( n++ < 100 )); do (time cp 10MB.dat /mnt/10MB.$n.dat) |& tee -a 10MB.results.txt; done
97``` 135```
98 136
99Files of size 100MB were not successfully transferred and ended up displaying error (cp: failed to close '/mnt/100MB.1.dat': Operation not permitted). 137Files of size 100MB were not successfully transferred and ended up displaying
138error (cp: failed to close '/mnt/100MB.1.dat': Operation not permitted).
100 139
101As I suspected, object size is not really that important. Sadly I don't have the time to test performance over periods of time. But if some of you would do it please send me your data. I would be interested in seeing results. 140As I suspected, object size is not really that important. Sadly I don't have
141the time to test performance over periods of time. But if some of you would do
142it please send me your data. I would be interested in seeing results.
102 143
103**Here are plotted results** 144**Here are plotted results**
104 145
105You can download [raw result here](/assets/do-fuse/copy-benchmarks.tsv). Measurements are in seconds. 146You can download [raw result here](/assets/do-fuse/copy-benchmarks.tsv).
147Measurements are in seconds.
106 148
107<script src="//cdn.plot.ly/plotly-latest.min.js"></script> 149<script src="//cdn.plot.ly/plotly-latest.min.js"></script>
108<div id="copy-benchmarks"></div> 150<div id="copy-benchmarks"></div>
@@ -135,11 +177,18 @@ You can download [raw result here](/assets/do-fuse/copy-benchmarks.tsv). Measure
135})(); 177})();
136</script> 178</script>
137 179
138As far as these tests show, performance is quite stable and can be predicted which is fantastic. But this is a small test and spans only over couple of hours. So you should not completely trust them. 180As far as these tests show, performance is quite stable and can be predicted
181which is fantastic. But this is a small test and spans only over couple of
182hours. So you should not completely trust them.
139 183
140### Measurement experiment 2: SQLite performanse 184### Measurement experiment 2: SQLite performanse
141 185
142I was unable to use database file directly from mounted drive so this is a no-go as I suspected. So I executed code below on a local disk just to get some benchmarks. I inserted 1000 records with DROPTABLE, CREATETABLE, INSERTMANY, FETCHALL, COMMIT for 1000 times to generate statistics. As you can see performance of SQLite is quite amazing. You could then potentially just copy file to mounted drive and be done with it. 186I was unable to use database file directly from mounted drive so this is a
187no-go as I suspected. So I executed code below on a local disk just to get
188some benchmarks. I inserted 1000 records with DROPTABLE, CREATETABLE,
189INSERTMANY, FETCHALL, COMMIT for 1000 times to generate statistics. As you can
190see performance of SQLite is quite amazing. You could then potentially just
191copy file to mounted drive and be done with it.
143 192
144```python 193```python
145import time 194import time
@@ -218,7 +267,11 @@ result_time = CLOSE = end_time - start_time
218print("CLOSE: %g seconds" % (result_time)) 267print("CLOSE: %g seconds" % (result_time))
219``` 268```
220 269
221You can download [raw result here](/assets/do-fuse/sqlite-benchmarks.tsv). And again, these results are done on a local block storage and do not represent capabilities of object storage. With my current approach and state of the test code these can not be done. I would need to make Python code much more robust and check locking etc. 270You can download [raw result here](/assets/do-fuse/sqlite-benchmarks.tsv). And
271again, these results are done on a local block storage and do not represent
272capabilities of object storage. With my current approach and state of the test
273code these can not be done. I would need to make Python code much more robust
274and check locking etc.
222 275
223<div id="sqlite-benchmarks"></div> 276<div id="sqlite-benchmarks"></div>
224<script> 277<script>
@@ -252,10 +305,24 @@ You can download [raw result here](/assets/do-fuse/sqlite-benchmarks.tsv). And a
252 305
253## Can storage be mounted on multiple machines at the same time and be writable? 306## Can storage be mounted on multiple machines at the same time and be writable?
254 307
255Well, this one didn't take long to test. And the answer is **YES**. I mounted space on both machines and measured same performance on both machines. But because file is downloaded before write and then uploaded on complete there could potentially be problems is another process is trying to access the same file. 308Well, this one didn't take long to test. And the answer is **YES**. I mounted
309space on both machines and measured same performance on both machines. But
310because file is downloaded before write and then uploaded on complete there
311could potentially be problems is another process is trying to access the same
312file.
256 313
257## Observations and conslusion 314## Observations and conslusion
258 315
259Using Spaces in this way makes it easier to access and manage files. But besides that you would need to write additional code to make this one play nice with you applications. 316Using Spaces in this way makes it easier to access and manage files. But
317besides that you would need to write additional code to make this one play
318nice with you applications.
319
320Nevertheless, this was extremely simple to setup and use and this is just
321another excellent product in DigitalOcean product line. I found this exercise
322very valuable and am thinking about implementing some sort of mechanism for
323SQLite, so data can be stored on Spaces and accessed by many VM's. For a
324project where data doesn't need to be accessible in real-time and can have
325couple of minutes old data this would be very interesting. If any of you find
326this proposal interesting please write in a comment box below or shoot me an
327email and I will keep you posted.
260 328
261Nevertheless, this was extremely simple to setup and use and this is just another excellent product in DigitalOcean product line. I found this exercise very valuable and am thinking about implementing some sort of mechanism for SQLite, so data can be stored on Spaces and accessed by many VM's. For a project where data doesn't need to be accessible in real-time and can have couple of minutes old data this would be very interesting. If any of you find this proposal interesting please write in a comment box below or shoot me an email and I will keep you posted.