diff options
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 | 152 |
1 files changed, 77 insertions, 75 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 bfc77ee..3a62594 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 | |||
| @@ -5,63 +5,67 @@ 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 | 8 | Couple of months ago [DigitalOcean](https://www.digitalocean.com) introduced new |
| 9 | new product called [Spaces](https://blog.digitalocean.com/introducing-spaces-object-storage/) | 9 | product called |
| 10 | which is Object Storage very similar to Amazon's S3. This really peaked my | 10 | [Spaces](https://blog.digitalocean.com/introducing-spaces-object-storage/) which |
| 11 | interest, because this was something I was missing and even the thought of | 11 | is Object Storage very similar to Amazon's S3. This really peaked my interest, |
| 12 | going over the internet for such functionality was in no interest to me. Also | 12 | because this was something I was missing and even the thought of going over the |
| 13 | in fashion with their previous pricing this also is very cheap and pricing | 13 | internet for such functionality was in no interest to me. Also in fashion with |
| 14 | page is a no-brainer compared to AWS or GCE. [Prices are clearly and precisely defined and outlined](https://www.digitalocean.com/pricing/). | 14 | their previous pricing this also is very cheap and pricing page is a no-brainer |
| 15 | You must love them for that :) | 15 | compared to AWS or GCE. [Prices are clearly and precisely defined and |
| 16 | outlined](https://www.digitalocean.com/pricing/). You must love them for that | ||
| 17 | :) | ||
| 16 | 18 | ||
| 17 | ## Initial requirements | 19 | ## Initial requirements |
| 18 | 20 | ||
| 19 | * Is it possible to use them as a mounted drive with FUSE? (tl;dr YES) | 21 | * Is it possible to use them as a mounted drive with FUSE? (tl;dr YES) |
| 20 | * Will the performance degrade over time and over different sizes of objects? | 22 | * Will the performance degrade over time and over different sizes of objects? |
| 21 | (tl;dr NO&YES) | 23 | (tl;dr NO&YES) |
| 22 | * Can storage be mounted on multiple machines at the same time and be writable? | 24 | * Can storage be mounted on multiple machines at the same time and be writable? |
| 23 | (tl;dr YES) | 25 | (tl;dr YES) |
| 24 | 26 | ||
| 25 | > Let me be clear. This scripts I use are made just for benchmarking and are | 27 | > Let me be clear. This scripts I use are made just for benchmarking and are not |
| 26 | > not intended to be used in real-life situations. Besides that, I am looking | 28 | > intended to be used in real-life situations. Besides that, I am looking into |
| 27 | > into using this approaches but adding caching service in front of it and then | 29 | > 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 | 30 | > 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 | 31 | > 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 | 32 | > eventual consistency please take this scripts as they are: not usable in such |
| 31 | > situations. | 33 | > situations. |
| 32 | 34 | ||
| 33 | ## Is it possible to use them as a mounted drive with FUSE? | 35 | ## Is it possible to use them as a mounted drive with FUSE? |
| 34 | 36 | ||
| 35 | Well, actually they can be used in such manor. Because they are similar to | 37 | Well, actually they can be used in such manor. Because they are similar to [AWS |
| 36 | [AWS S3](https://aws.amazon.com/s3/) many tools are available and you can find | 38 | S3](https://aws.amazon.com/s3/) many tools are available and you can find many |
| 37 | many articles and [Stackoverflow items](https://stackoverflow.com/search?q=s3+fuse). | 39 | articles and [Stackoverflow items](https://stackoverflow.com/search?q=s3+fuse). |
| 38 | 40 | ||
| 39 | To make this work you will need DigitalOcean account. If you don't have one you | 41 | 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 | 42 | 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). | 43 | [create new |
| 42 | If you click on this link you will already have preselected Debian 9 with | 44 | Droplet](https://cloud.digitalocean.com/droplets/new?size=s-1vcpu-1gb®ion=ams3&distro=debian&distroImage=debian-9-x64&options=private_networking,install_agent). |
| 45 | If you click on this link you will already have preselected Debian 9 with | ||
| 43 | smallest VM option. | 46 | smallest VM option. |
| 44 | 47 | ||
| 45 | * Please be sure to add you SSH key, because we will login to this machine | 48 | * Please be sure to add you SSH key, because we will login to this machine |
| 46 | remotely. | 49 | remotely. |
| 47 | * If you change your region please remember which one you choose because we | 50 | * If you change your region please remember which one you choose because we will |
| 48 | will need this information when we try to mount space to our machine. | 51 | need this information when we try to mount space to our machine. |
| 49 | 52 | ||
| 50 | Instuctions on how to use SSH keys and how to setup them are available in article | 53 | Instuctions on how to use SSH keys and how to setup them are available in |
| 51 | [How To Use SSH Keys with DigitalOcean Droplets](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-digitalocean-droplets). | 54 | article [How To Use SSH Keys with DigitalOcean |
| 55 | Droplets](https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-digitalocean-droplets). | ||
| 52 | 56 | ||
| 53 |  | 57 |  |
| 54 | 58 | ||
| 55 | After we created Droplet it's time to create new Space. This is done by clicking | 59 | 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 | 60 | on a button [Create](https://cloud.digitalocean.com/spaces/new) (right top |
| 57 | corner) and selecting Spaces. Choose pronounceable ```Unique name``` because we | 61 | 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 | 62 | 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. | 63 | doesn't matter in our case. And you can always change that in the future. |
| 60 | 64 | ||
| 61 | When you have created new Space we should [generate Access key](https://cloud.digitalocean.com/settings/api/tokens). | 65 | When you have created new Space we should [generate Access |
| 62 | This link will guide to the page when you can generate this key. After you | 66 | key](https://cloud.digitalocean.com/settings/api/tokens). This link will guide |
| 63 | create new one, please save provided Key and Secret because Secret will not | 67 | to the page when you can generate this key. After you create new one, please |
| 64 | be shown again. | 68 | save provided Key and Secret because Secret will not be shown again. |
| 65 | 69 | ||
| 66 |  | 70 |  |
| 67 | 71 | ||
| @@ -90,14 +94,13 @@ s3fs UNIQUE-NAME /mnt/ -ourl=https://ams3.digitaloceanspaces.com -ouse_cache=/tm | |||
| 90 | echo "Hello cruel world" > /mnt/hello.txt | 94 | echo "Hello cruel world" > /mnt/hello.txt |
| 91 | ``` | 95 | ``` |
| 92 | 96 | ||
| 93 | After all this you can return to your browser and go to | 97 | After all this you can return to your browser and go to [DigitalOcean |
| 94 | [DigitalOcean Spaces](https://cloud.digitalocean.com/spaces) and click on your | 98 | Spaces](https://cloud.digitalocean.com/spaces) and click on your created |
| 95 | created space. If file hello.txt is present you have successfully mounted | 99 | space. If file hello.txt is present you have successfully mounted space to your |
| 96 | space to your machine and wrote data to it. | 100 | machine and wrote data to it. |
| 97 | 101 | ||
| 98 | I choose the same region for my Droplet and my Space but you don't have to. | 102 | I choose the same region for my Droplet and my Space but you don't have to. You |
| 99 | You can have different regions. What this actually does to performance I | 103 | can have different regions. What this actually does to performance I don't know. |
| 100 | don't know. | ||
| 101 | 104 | ||
| 102 | Additional information on FUSE: | 105 | Additional information on FUSE: |
| 103 | 106 | ||
| @@ -106,9 +109,9 @@ Additional information on FUSE: | |||
| 106 | 109 | ||
| 107 | ## Will the performance degrade over time and over different sizes of objects? | 110 | ## Will the performance degrade over time and over different sizes of objects? |
| 108 | 111 | ||
| 109 | For this task I didn't want to just read and write text files or uploading | 112 | 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 | 113 | images. I actually wanted to figure out if using something like SQlite is viable |
| 111 | viable in this case. | 114 | in this case. |
| 112 | 115 | ||
| 113 | ### Measurement experiment 1: File copy | 116 | ### Measurement experiment 1: File copy |
| 114 | 117 | ||
| @@ -134,12 +137,12 @@ n=0; while (( n++ < 100 )); do (time cp 1MB.dat /mnt/1MB.$n.dat) |& tee -a 1MB.r | |||
| 134 | n=0; while (( n++ < 100 )); do (time cp 10MB.dat /mnt/10MB.$n.dat) |& tee -a 10MB.results.txt; done | 137 | n=0; while (( n++ < 100 )); do (time cp 10MB.dat /mnt/10MB.$n.dat) |& tee -a 10MB.results.txt; done |
| 135 | ``` | 138 | ``` |
| 136 | 139 | ||
| 137 | Files of size 100MB were not successfully transferred and ended up displaying | 140 | 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). | 141 | error (cp: failed to close '/mnt/100MB.1.dat': Operation not permitted). |
| 139 | 142 | ||
| 140 | As I suspected, object size is not really that important. Sadly I don't have | 143 | As I suspected, object size is not really that important. Sadly I don't have the |
| 141 | the time to test performance over periods of time. But if some of you would do | 144 | time to test performance over periods of time. But if some of you would do it |
| 142 | it please send me your data. I would be interested in seeing results. | 145 | please send me your data. I would be interested in seeing results. |
| 143 | 146 | ||
| 144 | **Here are plotted results** | 147 | **Here are plotted results** |
| 145 | 148 | ||
| @@ -177,18 +180,18 @@ Measurements are in seconds. | |||
| 177 | })(); | 180 | })(); |
| 178 | </script> | 181 | </script> |
| 179 | 182 | ||
| 180 | As far as these tests show, performance is quite stable and can be predicted | 183 | 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 | 184 | which is fantastic. But this is a small test and spans only over couple of |
| 182 | hours. So you should not completely trust them. | 185 | hours. So you should not completely trust them. |
| 183 | 186 | ||
| 184 | ### Measurement experiment 2: SQLite performanse | 187 | ### Measurement experiment 2: SQLite performanse |
| 185 | 188 | ||
| 186 | I was unable to use database file directly from mounted drive so this is a | 189 | I was unable to use database file directly from mounted drive so this is a no-go |
| 187 | no-go as I suspected. So I executed code below on a local disk just to get | 190 | as I suspected. So I executed code below on a local disk just to get some |
| 188 | some benchmarks. I inserted 1000 records with DROPTABLE, CREATETABLE, | 191 | benchmarks. I inserted 1000 records with DROPTABLE, CREATETABLE, INSERTMANY, |
| 189 | INSERTMANY, FETCHALL, COMMIT for 1000 times to generate statistics. As you can | 192 | FETCHALL, COMMIT for 1000 times to generate statistics. As you can see |
| 190 | see performance of SQLite is quite amazing. You could then potentially just | 193 | performance of SQLite is quite amazing. You could then potentially just copy |
| 191 | copy file to mounted drive and be done with it. | 194 | file to mounted drive and be done with it. |
| 192 | 195 | ||
| 193 | ```python | 196 | ```python |
| 194 | import time | 197 | import time |
| @@ -305,24 +308,23 @@ and check locking etc. | |||
| 305 | 308 | ||
| 306 | ## Can storage be mounted on multiple machines at the same time and be writable? | 309 | ## Can storage be mounted on multiple machines at the same time and be writable? |
| 307 | 310 | ||
| 308 | Well, this one didn't take long to test. And the answer is **YES**. I mounted | 311 | 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 | 312 | 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 | 313 | 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 | 314 | could potentially be problems is another process is trying to access the same |
| 312 | file. | 315 | file. |
| 313 | 316 | ||
| 314 | ## Observations and conslusion | 317 | ## Observations and conslusion |
| 315 | 318 | ||
| 316 | Using Spaces in this way makes it easier to access and manage files. But | 319 | Using Spaces in this way makes it easier to access and manage files. But besides |
| 317 | besides that you would need to write additional code to make this one play | 320 | that you would need to write additional code to make this one play nice with you |
| 318 | nice with you applications. | 321 | applications. |
| 319 | 322 | ||
| 320 | Nevertheless, this was extremely simple to setup and use and this is just | 323 | 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 | 324 | another excellent product in DigitalOcean product line. I found this exercise |
| 322 | very valuable and am thinking about implementing some sort of mechanism for | 325 | 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 | 326 | SQLite, so data can be stored on Spaces and accessed by many VM's. For a project |
| 324 | project where data doesn't need to be accessible in real-time and can have | 327 | where data doesn't need to be accessible in real-time and can have couple of |
| 325 | couple of minutes old data this would be very interesting. If any of you find | 328 | minutes old data this would be very interesting. If any of you find this |
| 326 | this proposal interesting please write in a comment box below or shoot me an | 329 | proposal interesting please write in a comment box below or shoot me an email |
| 327 | email and I will keep you posted. | 330 | and I will keep you posted. |
| 328 | |||
