diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2023-05-26 00:40:40 +0200 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2023-05-26 00:40:40 +0200 |
| commit | 43b0708769eb61392050045b881f8e6ba39c5b66 (patch) | |
| tree | 3939579a13b8325325d5ebb8e05324a41ed78a6d /content/posts/2018-01-16-using-digitalocean-spaces-object-storage-with-fuse.md | |
| parent | 49e7e7d555a6cd9810d81561fa3e98e3d64502be (diff) | |
| download | mitjafelicijan.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.md | 117 |
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 | --- |
| 2 | title: Using DigitalOcean Spaces Object Storage with FUSE | 2 | title: Using DigitalOcean Spaces Object Storage with FUSE |
| 3 | url: using-digitalocean-spaces-object-storage-with-fuse.html | 3 | url: using-digitalocean-spaces-object-storage-with-fuse.html |
| 4 | date: 2018-01-16 | 4 | date: 2018-01-16T12:00:00+02:00 |
| 5 | draft: false | 5 | draft: false |
| 6 | --- | 6 | --- |
| 7 | 7 | ||
| 8 | Couple 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 :) | 8 | Couple of months ago [DigitalOcean](https://www.digitalocean.com) introduced |
| 9 | new product called [Spaces](https://blog.digitalocean.com/introducing-spaces-object-storage/) | ||
| 10 | which is Object Storage very similar to Amazon's S3. This really peaked my | ||
| 11 | interest, because this was something I was missing and even the thought of | ||
| 12 | going over the internet for such functionality was in no interest to me. Also | ||
| 13 | in fashion with their previous pricing this also is very cheap and pricing | ||
| 14 | page is a no-brainer compared to AWS or GCE. [Prices are clearly and precisely defined and outlined](https://www.digitalocean.com/pricing/). | ||
| 15 | You 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 | ||
| 20 | Well, 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). | 35 | Well, 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 | ||
| 37 | many articles and [Stackoverflow items](https://stackoverflow.com/search?q=s3+fuse). | ||
| 21 | 38 | ||
| 22 | To 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®ion=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. | 39 | To make this work you will need DigitalOcean account. If you don't have one you |
| 40 | will 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®ion=ams3&distro=debian&distroImage=debian-9-x64&options=private_networking,install_agent). | ||
| 42 | If you click on this link you will already have preselected Debian 9 with | ||
| 43 | smallest 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 | ||
| 27 | Instuctions 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). | 50 | Instuctions 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 |  | 53 |  |
| 30 | 54 | ||
| 31 | After 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. | 55 | After we created Droplet it's time to create new Space. This is done by clicking |
| 56 | on a button [Create](https://cloud.digitalocean.com/spaces/new) (right top | ||
| 57 | corner) and selecting Spaces. Choose pronounceable ```Unique name``` because we | ||
| 58 | will use it in examples below. You can either choose Private or Public, it | ||
| 59 | doesn't matter in our case. And you can always change that in the future. | ||
| 32 | 60 | ||
| 33 | When 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. | 61 | When you have created new Space we should [generate Access key](https://cloud.digitalocean.com/settings/api/tokens). |
| 62 | This link will guide to the page when you can generate this key. After you | ||
| 63 | create new one, please save provided Key and Secret because Secret will not | ||
| 64 | be shown again. | ||
| 34 | 65 | ||
| 35 |  | 66 |  |
| 36 | 67 | ||
| @@ -59,9 +90,14 @@ s3fs UNIQUE-NAME /mnt/ -ourl=https://ams3.digitaloceanspaces.com -ouse_cache=/tm | |||
| 59 | echo "Hello cruel world" > /mnt/hello.txt | 90 | echo "Hello cruel world" > /mnt/hello.txt |
| 60 | ``` | 91 | ``` |
| 61 | 92 | ||
| 62 | After 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. | 93 | After all this you can return to your browser and go to |
| 94 | [DigitalOcean Spaces](https://cloud.digitalocean.com/spaces) and click on your | ||
| 95 | created space. If file hello.txt is present you have successfully mounted | ||
| 96 | space to your machine and wrote data to it. | ||
| 63 | 97 | ||
| 64 | I 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. | 98 | I choose the same region for my Droplet and my Space but you don't have to. |
| 99 | You can have different regions. What this actually does to performance I | ||
| 100 | don't know. | ||
| 65 | 101 | ||
| 66 | Additional information on FUSE: | 102 | Additional 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 | ||
| 73 | For 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. | 109 | For this task I didn't want to just read and write text files or uploading |
| 110 | images. I actually wanted to figure out if using something like SQlite is | ||
| 111 | viable 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 | |||
| 96 | n=0; while (( n++ < 100 )); do (time cp 10MB.dat /mnt/10MB.$n.dat) |& tee -a 10MB.results.txt; done | 134 | n=0; while (( n++ < 100 )); do (time cp 10MB.dat /mnt/10MB.$n.dat) |& tee -a 10MB.results.txt; done |
| 97 | ``` | 135 | ``` |
| 98 | 136 | ||
| 99 | Files of size 100MB were not successfully transferred and ended up displaying error (cp: failed to close '/mnt/100MB.1.dat': Operation not permitted). | 137 | Files of size 100MB were not successfully transferred and ended up displaying |
| 138 | error (cp: failed to close '/mnt/100MB.1.dat': Operation not permitted). | ||
| 100 | 139 | ||
| 101 | As 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. | 140 | As I suspected, object size is not really that important. Sadly I don't have |
| 141 | the time to test performance over periods of time. But if some of you would do | ||
| 142 | it 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 | ||
| 105 | You can download [raw result here](/assets/do-fuse/copy-benchmarks.tsv). Measurements are in seconds. | 146 | You can download [raw result here](/assets/do-fuse/copy-benchmarks.tsv). |
| 147 | Measurements 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 | ||
| 138 | As 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. | 180 | As far as these tests show, performance is quite stable and can be predicted |
| 181 | which is fantastic. But this is a small test and spans only over couple of | ||
| 182 | hours. So you should not completely trust them. | ||
| 139 | 183 | ||
| 140 | ### Measurement experiment 2: SQLite performanse | 184 | ### Measurement experiment 2: SQLite performanse |
| 141 | 185 | ||
| 142 | I 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. | 186 | I was unable to use database file directly from mounted drive so this is a |
| 187 | no-go as I suspected. So I executed code below on a local disk just to get | ||
| 188 | some benchmarks. I inserted 1000 records with DROPTABLE, CREATETABLE, | ||
| 189 | INSERTMANY, FETCHALL, COMMIT for 1000 times to generate statistics. As you can | ||
| 190 | see performance of SQLite is quite amazing. You could then potentially just | ||
| 191 | copy file to mounted drive and be done with it. | ||
| 143 | 192 | ||
| 144 | ```python | 193 | ```python |
| 145 | import time | 194 | import time |
| @@ -218,7 +267,11 @@ result_time = CLOSE = end_time - start_time | |||
| 218 | print("CLOSE: %g seconds" % (result_time)) | 267 | print("CLOSE: %g seconds" % (result_time)) |
| 219 | ``` | 268 | ``` |
| 220 | 269 | ||
| 221 | You 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. | 270 | You can download [raw result here](/assets/do-fuse/sqlite-benchmarks.tsv). And |
| 271 | again, these results are done on a local block storage and do not represent | ||
| 272 | capabilities of object storage. With my current approach and state of the test | ||
| 273 | code these can not be done. I would need to make Python code much more robust | ||
| 274 | and 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 | ||
| 255 | Well, 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. | 308 | Well, this one didn't take long to test. And the answer is **YES**. I mounted |
| 309 | space on both machines and measured same performance on both machines. But | ||
| 310 | because file is downloaded before write and then uploaded on complete there | ||
| 311 | could potentially be problems is another process is trying to access the same | ||
| 312 | file. | ||
| 256 | 313 | ||
| 257 | ## Observations and conslusion | 314 | ## Observations and conslusion |
| 258 | 315 | ||
| 259 | Using 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. | 316 | Using Spaces in this way makes it easier to access and manage files. But |
| 317 | besides that you would need to write additional code to make this one play | ||
| 318 | nice with you applications. | ||
| 319 | |||
| 320 | Nevertheless, this was extremely simple to setup and use and this is just | ||
| 321 | another excellent product in DigitalOcean product line. I found this exercise | ||
| 322 | very valuable and am thinking about implementing some sort of mechanism for | ||
| 323 | SQLite, so data can be stored on Spaces and accessed by many VM's. For a | ||
| 324 | project where data doesn't need to be accessible in real-time and can have | ||
| 325 | couple of minutes old data this would be very interesting. If any of you find | ||
| 326 | this proposal interesting please write in a comment box below or shoot me an | ||
| 327 | email and I will keep you posted. | ||
| 260 | 328 | ||
| 261 | Nevertheless, 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. | ||
