<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alex Chan on Medium]]></title>
        <description><![CDATA[Stories by Alex Chan on Medium]]></description>
        <link>https://medium.com/@alexwlchan?source=rss-e34c74a2c5d3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FHgqfFgM7-v98DMEogRHrg.jpeg</url>
            <title>Stories by Alex Chan on Medium</title>
            <link>https://medium.com/@alexwlchan?source=rss-e34c74a2c5d3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 09:46:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alexwlchan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How moving to the cloud took our digital collections to new heights]]></title>
            <link>https://stacks.wellcomecollection.org/how-moving-to-the-cloud-took-our-digital-collections-to-new-heights-2dc5a896f0be?source=rss-e34c74a2c5d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dc5a896f0be</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[digital-preservation]]></category>
            <category><![CDATA[museums]]></category>
            <dc:creator><![CDATA[Alex Chan]]></dc:creator>
            <pubDate>Thu, 09 Feb 2023 13:12:26 GMT</pubDate>
            <atom:updated>2023-02-09T13:12:26.002Z</atom:updated>
            <content:encoded><![CDATA[<p>We want to provide free and unrestricted access to our collections, and we digitise our collections so that we can <a href="https://wellcomecollection.org/collections">make them available online</a>. We’ve already digitised hundreds of thousands of items, and put millions of images online — but there’s plenty more to do!</p><p>Over the last few years, we’ve moved a lot of our back-end systems into the cloud. This has opened new possibilities for how we manage our digital collections — <strong>it’s not just a drop-in replacement, it’s a step change in what we can do.</strong></p><figure><img alt="Three old computers on a wooden desk in the library. There are two monitors, one showing a digital image — some sort of engraving — the other showing some text. Next to them is the “Iconographic Library Videodisc”, which was an output of our early digitisation programme." src="https://cdn-images-1.medium.com/max/1024/1*s980mn8T3qc4E3ZB8utMhg.jpeg" /><figcaption>Digitisation has come a long way since the days of video discs and CRT monitors. Photo: <a href="https://wellcomecollection.org/works/vcv33pch/images?id=maf9tq89">Wellcome Collection</a>.</figcaption></figure><h3>How we manage our digital collections</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cZUqHLtvgP7ZqUv2uRb4bA.png" /></figure><p>We get some files, either directly from our in-house digitisation team, sent by one of our external digitisation vendors, or born-digital files given to us by a donor.</p><p>These go through workflow tools which do certain processing steps, like file format identification and adding fixity checksums. For digitised material we use <a href="https://www.intranda.com/en/digiverso/goobi/goobi-overview/">Goobi</a>; for born-digital material we use <a href="https://www.archivematica.org/en/">Archivematica</a>. This creates additional metadata which is stored with the files.</p><p>The processed files are then uploaded to permanent storage, and where possible published online through open, freely-available <a href="https://iiif.io/api/">IIIF APIs</a>. (Not all of our digital collections are available; a subset is restricted or closed in line with <a href="https://wellcomecollection.org/pages/Wvmu3yAAAIUQ4C7F#access-policy">our Access Policy</a>, e.g. if the files contain personal information about living people.)</p><p>Previously, all of this processing happened on-site, and our files were kept in a mixture of on-premise RAID storage and Amazon S3. We’ve moved this entire process to the cloud, and that gives us a number of very tangible benefits.</p><h3>What do we get from the cloud?</h3><h4>We can store much bigger files</h4><p>We replaced our on-premise storage with <a href="https://stacks.wellcomecollection.org/building-wellcome-collections-new-archival-storage-service-3f68ff21927e">a new, open-source storage service</a> that’s backed by Amazon S3 and Azure Blob. These cloud services allow you to upload as much data as you like, which is more flexible than our on-prem setup. Previously, new storage had to be ordered weeks or months in advance — but never again will we have to pause our collecting while we wait for new hard drives.</p><p>One place where we’ve taken advantage of this flexibility is in our audiovisual collections. When we started processing and ingesting <a href="https://stacks.wellcomecollection.org/audiovisual-workflows-for-digital-preservation-8c071ca39e96">AV material in the cloud</a>, we could move from compressed MPEG2 files to higher quality 2K or 4K files. The higher quality files are much bigger, and obviously more desirable from a preservation point of view, but with our on-premise storage we didn’t have the capacity for that much data. <strong>The cloud can not only store these larger files, but it can store them in </strong><a href="https://stacks.wellcomecollection.org/large-things-living-in-cold-places-66cbc3603e14"><strong>a cost-effective way</strong></a><strong>.</strong></p><p>This is one example of how moving to the cloud has allowed us to make more decisions based on what’s best for the collections, not our technical limitations.</p><h4>We can go much faster</h4><p>Our on-premise workflow tools had a fixed capacity, and we’d often hit it! If we got a particularly large batch of new files, those services would get backed up, and sometimes take days or weeks to clear their queues. The queues would clear eventually, but this bottleneck was a limit on our ability to increase our rate of digitisation.</p><p><strong>All our cloud services are “elastic” — they can scale up or down based on the work available.</strong> At midday on a Tuesday, they’ll be using lots of resources. If you come back at 2am on Sunday, nothing will be running. This means that when a big batch of material arrives, they’ll add more processing capacity to deal with it — and then take it away when it’s done. Now this bottleneck is removed, new material will appear much sooner after it’s digitised.</p><p>This also means we don’t need to pass files around the on-site network or download them to our laptops — we can work on them directly in the cloud. This is a big win, especially in the age of hybrid working, when not everybody has a fast Internet connection at home — less time waiting to move files around.</p><h4>We can reprocess content at scale</h4><p>Because we have so much capacity, we can do the sort of bulk processing that simply wasn’t feasible in our old system. We have ~100M objects in our permanent storage, but we could reprocess them all in a matter of hours.</p><p><strong>One benefit of this is that we don’t need to fixate on picking the one and only “correct” file format for our digital objects. </strong>We can convert files into new formats whenever we like, so now we store highest-quality preservation files, and then we create access copies from the preservation copy in different formats. As file format fashion changes, we can create new access copies.</p><p>For example, we have a growing pile of Word documents and PowerPoint decks in our born-digital collections. Currently we just store the original file, but at some point we might create PDF derivatives as access copies — and we could do that for all our existing files, not just new ingests. We’re not bound by decisions we’ve already made; we can migrate our digital collections as our needs evolve.</p><p>All this means we can handle more files, larger files, and more complex digital objects. We can be more ambitious about the sort of digitisation projects we undertake.</p><h4>It’s easier to receive files</h4><p>A few months after I started at Wellcome, we got a new batch of files from a vendor in Cambridge. I drove over to their office, collected a box full of hard drives, wrapped it in towels and bubble wrap, and carried it back to London on the train. Being jostled on the Tube has never been more stressful.</p><p>The files arrived safely, but this is obviously sub-optimal.</p><p>Vendors can now deliver files directly into our S3 buckets, which is simpler, more secure, and allows us to have lots of small deliveries rather than waiting for one massive batch.</p><h3>Where next?</h3><p>It’s important to acknowledge the complexity of moving all our storage and data management to the cloud. It was a multi-year process that required a lot of collaboration between teams, we had to add new skills and people, and it took careful planning and delivery. This wasn’t a quick win.</p><p>And it’s not “done” — running this sort of platform is a continuous process. We’ll continue to maintain and extend this infrastructure, and we’ll continue to grow our digital collections — adding 4 to 5 million new images a year. New bottlenecks and bugs will emerge, and we’ll address them as they do.</p><p>The cost of this setup is very manageable. Our storage cost scales linearly at a steady ~$25/TB, and that’s for all three copies of our content. Our processing cost is pretty stable, and doesn’t vary much month-to-month.</p><p>We’re about to roll our performance improvements to our image servers — as more and more people visit our website, we want to keep it fast and speedy. We’re also looking at presenting born-digital material on our website, so you can browse those files as easily as our digitised collections. And there’s plenty more to come after that.</p><p>Looking back, the benefits of building our own platform are clear. It’s more than just numbers on a spreadsheet or abstract technical advances. <strong>We’ve removed technical limitations, which means we can make more decisions based on what’s best for the collections, and not be limited by our digital infrastructure.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2dc5a896f0be" width="1" height="1" alt=""><hr><p><a href="https://stacks.wellcomecollection.org/how-moving-to-the-cloud-took-our-digital-collections-to-new-heights-2dc5a896f0be">How moving to the cloud took our digital collections to new heights</a> was originally published in <a href="https://stacks.wellcomecollection.org/">Stacks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building our new unified collections search]]></title>
            <link>https://stacks.wellcomecollection.org/building-our-new-unified-collections-search-ed399c412b01?source=rss-e34c74a2c5d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed399c412b01</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[libraries]]></category>
            <category><![CDATA[search]]></category>
            <dc:creator><![CDATA[Alex Chan]]></dc:creator>
            <pubDate>Mon, 29 Mar 2021 10:48:12 GMT</pubDate>
            <atom:updated>2021-03-29T10:48:12.797Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>One of the key features of the new Wellcome Collection website is our <a href="https://wellcomecollection.org/collections">unified collections search</a>.</p><figure><img alt="A search box labelled “Search the catalogue” with two tabs: “Library catalogue” and “Images”. To the right is a green button labelled “Search”. The search is for “suez canal” and shows two search results." src="https://cdn-images-1.medium.com/max/1024/1*yylbOkcv7M-D5CcYOt2u3w.png" /></figure><p>On the old Wellcome Library and Wellcome Images websites, we had different search tools for different types of records. Each tool would present a different view of the data, and you had to work out which tool would find the information you needed.</p><p>We had one tool that would search all our catalogues, but it lost a lot of the structure from the underlying data. We had other tools that would preserve the structure and detail, but only included a subset of the catalogue. Yet another tool would search our image collections. Our new search no longer forces you to choose: <strong>a single search box searches everything, and with all the detail and functionality our users expect.</strong></p><p>This has been a significant technical challenge, with input from teams across Wellcome Collection. In this post, I’m going to explain how we built this feature.</p><h3>Why did we have different search boxes?</h3><figure><img alt="Screenshot of the “Which search tool should I use?” page from the old Library website." src="https://cdn-images-1.medium.com/max/1024/1*NlNlV_i2hio5htAGADHvIw.png" /><figcaption>You won’t find this page on our new website.</figcaption></figure><p>Like many institutions, our collections data is split across multiple systems — including Calm for our archives, <a href="https://www.iii.com/products/sierra-ils/">Sierra</a> for our library catalogue, an image asset catalogue called Miro, and our <a href="https://stacks.wellcomecollection.org/building-wellcome-collections-new-archival-storage-service-3f68ff21927e">cloud storage</a> for digitised material. Each system is designed to store a particular kind of data, and there’s no one-size-fits-all system that could record all our collections in the level of detail we want.</p><p>The different search boxes were for searching different systems, and a user had to know how and where we might have recorded something. The different systems are important to our collections team, but we didn’t want online visitors to have to worry about this distinction.</p><h3>How our unified search works</h3><h4>Create a read-only copy of every source catalogue</h4><p>Our catalogue data is split across different systems, and each of those systems has its own API for accessing the data. The first step is to build some services that use those APIs to read data out of each system.</p><figure><img alt="A diagram showing arrows from three APIs on the left to three databases on the right. Each API/database pair has a different brown/cream-coloured shape." src="https://cdn-images-1.medium.com/max/1024/1*ze-zPsDn5J7EanZ_JwlzvQ.png" /></figure><p>To minimise load on the source systems, we read the data out once, and then we save it to a database that we manage (one database per source). As records are edited or created, we update the copy in our own database — and that’s what we use for the website search.</p><p>This gives us a copy of the data that we can query or transform extremely quickly, without slowing down or affecting the source systems.</p><p>We call these services <em>“adapters”</em>. Like an electrical plug, these adapters provide a common interface — in this case, for getting data from our source systems. The adapters handle all the complexity of talking to the source system APIs, and all our other services can read from the managed databases, regardless of the original source system.</p><p>As much as possible, we store an exact copy of the data as we received it from the original system. At this stage, we try not to do any processing or transformation.</p><p>This is a read-only copy of the data. We’re not trying to replace or supplant the source systems as the canonical copy of our catalogue. Doing so would be massively disruptive, and add very little value to this process.</p><p>Right now, our adapters only pull in catalogue records, but this approach would allow us to bring in other types of data that don’t traditionally live in a catalogue — things like OCR for our digitised items, <a href="https://stacks.wellcomecollection.org/tei-for-manuscript-description-at-wellcome-collection-a2b8f52524e2">TEI descriptions of manuscripts</a>, or the output from <a href="https://stacks.wellcomecollection.org/a-new-kind-of-image-search-5870c2cdadcb">our machine learning models</a>.</p><h3>Transform each record into a common model</h3><p>All of our source catalogues store data in a different way — for example, our archives catalogue uses <a href="https://en.wikipedia.org/wiki/ISAD(G)">ISAD(G)</a>, whereas our library catalogue uses <a href="https://en.wikipedia.org/wiki/MARC_standards">MARC</a>.</p><p>We could build a unified search by searching every catalogue individually, and then combining the results — but putting the results in a sensible order would be very tricky.</p><figure><img alt="The brown shapes from the previous diagram being transformed into green circles." src="https://cdn-images-1.medium.com/max/1024/1*_X5vD-np5M3K4NtAo_8qdw.png" /></figure><p>Instead, we transform each of the source records into a common model — so we can store and search them as one big collection. This common model is called a <a href="https://developers.wellcomecollection.org/catalogue/v2/models/work">“Work”</a>, and we’ve designed it so that it can store all the data we want to present publicly.</p><p>Using a new model — rather than using one of the models from the source records — allows us to keep all the structure of the source catalogues. Among other things, it preserves the hierarchy and relationships between works in our archives catalogue. The combined search on our old website squashed ISAD(G) into MARC, which lost a lot of this structure and made archives harder to navigate. Our new model has no such restrictions.</p><p>We have a different transformation process for each source catalogue, based on how it structures its data. For example, the “title” on a Work created from our Calm catalogue comes from the “Title” field, whereas a Work from our Sierra catalogue uses MARC field 245. These processes are very Wellcome-specific, and they come from lots of conversations between our collections and digital teams. We tweak the transformation on a regular basis, to try to improve the quality of data on a Work.</p><h3>Combine works that refer to the “same” thing</h3><p>Sometimes we have multiple source records that describe the same object, and we want to combine them into a single Work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UcfhxyQ2WkPINF-AkBvHvA.png" /></figure><p>For example, we might have a library book that we’ve digitised. This would have (at least) two records: one in the library catalogue, one in our cloud storage. We want to combine these together, so that if somebody comes to the page for the library catalogue record, they’ll see the digitised copy of the book on the same page.</p><p>We look for matching identifiers in the source records, and if we find any, we try to merge the resulting Works into a single Work (and redirect the others to this new Work). The merging process combines the data from all the individual Works according to a set of rules which are designed as a close collaboration between our digital team and collections staff. As the original records get updated, we update these merges, combining or splitting Works to reflect the latest data in the underlying catalogue.</p><h3>Add a new identifier</h3><p>All of our catalogue systems use different identifier schemes. One system might use UUIDs, another an auto-incrementing integer, another a human-written reference number. We didn’t want to rely on any of these schemes — we wanted something that would look consistent, and which was independent of those systems. If we replace one of our catalogue systems, we want our IDs and our website URLs to keep working.</p><p>When we were deciding how to identify works, we came up with a couple of desirable properties:</p><ul><li><em>Identifiers should be URL safe. </em>Each Work has a page at /works/{id}, so we want an ID that you can put in a URL.</li><li><em>Identifiers should be short.</em> This is what I call the “post-it note test”: could somebody scribble down an ID on a post-it note, and still read it later?</li><li><em>No ambiguous characters</em>. Similar-looking characters like o/O/0 or l/I cause all manner of confusion, and we’d prefer not to use them.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HBBGURDF4ce5jqi7IzcHNQ.png" /></figure><p>We generate our own “canonical” identifiers, which look like <em>jn3aavyr</em> or <em>xwkfdhhz</em>. Even with ambiguous characters removed, that gives us nearly a trillion identifiers, which is plenty.</p><p>We always generate exactly one canonical identifier for each source identifier — they are meant to augment the existing source identifiers, not replace them.</p><h3>Put the works in a search index</h3><p>We put every work in the same search index — regardless of source system. By running queries against that index, we can search records from across all of our catalogues, and get a single set of results.</p><figure><img alt="Works being copied to a search index. Three green circles and arrows going to a database with a magnifying glass icon." src="https://cdn-images-1.medium.com/max/1024/1*O5oZzA-gzWzMfbwbl8o5Pw.png" /></figure><p>We have a publicly available <a href="https://developers.wellcomecollection.org/catalogue">Catalogue API</a> that anybody can use to search our collections, and we use the same API for the search on our website. This API is making queries directly against the search index, and includes filters and aggregations to help people narrow down what they’re looking for.</p><p>Over time, we can tweak the queries, which we hope will improve the quality of search results. For example, we can adjust the importance of certain fields, change how the data is analysed, or vary the amount of fuzziness allowed when matching a word.</p><h3>Putting it all together</h3><p>This is a fairly standard <a href="https://en.wikipedia.org/wiki/Extract,_transform,_load">ETL pipeline</a>. We <strong>extract</strong> data from our catalogue systems, we <strong>transform</strong> it into our common Work model, and we <strong>load</strong> it into a search index.</p><p>This system is pretty flexible, and will allow us to add more sources in future. These could be entirely new catalogues, or data to enrich our existing works.</p><p>The hard part is, as ever, understanding the context. We can extract and load the data pretty easily, but we can only write the transformation process when we know what the data means. What is this field used for? How is this sort of record catalogued? How do our collections team think about this data? And so on.</p><p><strong>Building our unified collections search has been an iterative, collaborative process.</strong> There are lots of conversations between our digital and collections teams, trying to get us all to a common understanding of how our catalogues work. We use that understanding to design and implement the transformation process — and in turn, we have more conversations when people can see the output. We’re continually tweaking and improving how this pipeline works.</p><p><em>Thanks to Ashley Ray, Christy Henshaw, Jamie Parkinson, Lalita Kaplish and Tom Scott for their help reviewing drafts of this post.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed399c412b01" width="1" height="1" alt=""><hr><p><a href="https://stacks.wellcomecollection.org/building-our-new-unified-collections-search-ed399c412b01">Building our new unified collections search</a> was originally published in <a href="https://stacks.wellcomecollection.org/">Stacks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Our approach to digital verification]]></title>
            <link>https://stacks.wellcomecollection.org/our-approach-to-digital-verification-79da59da4ab7?source=rss-e34c74a2c5d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/79da59da4ab7</guid>
            <category><![CDATA[digital-preservation]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[museums]]></category>
            <dc:creator><![CDATA[Alex Chan]]></dc:creator>
            <pubDate>Mon, 18 Jan 2021 12:13:03 GMT</pubDate>
            <atom:updated>2021-01-18T12:13:03.538Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>As an archive, we have a responsibility to preserve and maintain our collections, and this is just as true of digital files as of physical objects. But digital media is fragile: we can’t just save our files on a hard drive, lock it in a cupboard, and hope for the best. Disks fail, data decays, and files get corrupted. Unlike paper, which degrades slowly and might remain readable for centuries, a single error can render a digital file completely unreadable.</p><p>To ensure our digital collections are preserved for years to come, we have a set of rigorous checks and verifications that run against every digital file we store in the archive. This includes verifying checksums, validating filenames, and checking we have the right number of files.</p><p>In this post, I’m going to explain how we decide which checks to run, and when we run them. Our approach is deliberately quite broad and general, and could apply to any digital preservation repository — regardless of size, tech stack, or storage medium.</p><figure><img alt="A black and white etching of of three men wearing Victorian era clothing looking into a microscope with three tubes." src="https://cdn-images-1.medium.com/max/1024/1*t9suJx0cwmshdrAdkcK46Q.jpeg" /><figcaption>Every aspect of a file must be examined closely, to rule out the possibility of corruption or error. Used under CC BY, image from <a href="https://wellcomecollection.org/works/gjwa5nef">Wellcome Collection</a>.</figcaption></figure><h3>What we verify</h3><h4>Are files packaged in BagIt bags?</h4><p>We use the <a href="https://tools.ietf.org/html/rfc8493">BagIt packaging format</a> to organise files in our digital archive. When you want to store new files in the archive, you put those files in a BagIt “bag” and send them to our <a href="https://stacks.wellcomecollection.org/building-wellcome-collections-new-archival-storage-service-3f68ff21927e">storage service</a>; files in the same bag get stored and processed together. As well as the files, a BagIt bag includes some metadata and checksums that describe the files it contains.</p><p>We use BagIt because it’s an open standard, and we believe it will continue to be readable for a long time.</p><p>The longevity of BagIt is only useful if we’re actually storing valid BagIt bags, so we check that every bag we store matches the BagIt specification. This includes checking that we can parse the BagIt metadata files, and that the metadata is an accurate description of the bag. For example, the BagIt <em>Payload-Oxum </em>field describes the number and size of the files in the bag, and we check that it’s correct.</p><h4>Do files have the correct checksums?</h4><p>A <a href="https://en.wikipedia.org/wiki/Checksum"><em>checksum</em></a> is a short value that can be used to check that no errors have been introduced when copying data. You use a <em>checksum algorithm </em>(e.g. MD5, SHA-1) to create a checksum for a piece of data (say, a file you want to store), and the same file will always have the same checksum.</p><p>If you store a file and it has the same checksum in a year’s time as it does today, you can be reasonably sure it hasn’t changed. But if you store a file and later it has a different checksum, something has changed. This tells you the file has been modified or corrupted, and you need to take action to repair it.</p><p>BagIt metadata includes a checksum for every file in a bag. We verify the checksum of every file in the archive, so we know it’s the same file we were originally sent.</p><p>We currently use <a href="https://en.wikipedia.org/wiki/SHA-2">the SHA-256 checksum algorithm</a> to verify our files, although both BagIt and our storage service are flexible enough to support checksums with multiple algorithms for the same file. We can choose to add checksums using other algorithms later, if we decide it would be useful.</p><h4>Explicit checks are better than implicit assumptions</h4><p>Once something is in the digital archive, it’s intentionally very hard to modify or remove — and once it’s in, we have to store it, keep it safe, and support it with all our tooling.</p><p>Because of this, we’ve designed the storage service to be quite conservative about what it lets in. In certain cases, we’ve made assumptions about the files and bags in the archive (for example, <em>“every bag has an alphanumeric identifier”</em>), and we encode those assumptions as explicit checks. If a bag turns up that breaks our assumptions, the failing check makes it very visible.</p><p>These checks aren’t iron-clad, immutable rules; they’re an opening to a discussion. If somebody tries to store a bag or file which breaks one of these assumptions, it means there’s a misunderstanding somewhere. Either they don’t understand how the storage service works, or they have a use case the developers haven’t considered. An explicit check forces this misunderstanding into the open, so we can discuss how best to handle it — rather than the bag slipping in silently, and causing unexpected issues later.</p><h3>When we verify</h3><p>We verify every file <strong>before copying it to permanent storage</strong>. We only copy files to permanent storage after they’ve passed all the checks. If a file fails checking, we reject it and explain to the user why we couldn’t accept it.</p><p>If we copied unverified files directly to permanent storage, we might store a broken file. We’d then need something to record which files were broken, or design some rollback mechanism to remove that file from the storage. Both of those increase the risk of bugs or mistakes which might affect the integrity of the archive. Keeping unverified files away from the permanent storage avoids that risk, and keeps the storage service simpler.</p><p>Then we re-verify every file <strong>after copying it to permanent storage</strong>. We know we received valid files, but something could go wrong in the copying process. There could be a bug in the copying code that means it copies the wrong file, or stores an incomplete copy, or stores it in the wrong place. We re-run all our checks every time we copy a file to a new location, so we can detect any such bugs immediately.</p><p>Finally, we ensure our files are <strong>continually verified at rest</strong>. It’s not enough to verify files once, and leave them. Because digital storage media <a href="https://en.wikipedia.org/wiki/Data_degradation">degrades over time</a>, digital files need to be continually verified and repaired if you want them to remain usable.</p><p>All of the files in our digital archive are stored in the cloud, specifically <a href="https://aws.amazon.com/s3/">Amazon S3</a> and <a href="https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction">Azure Blob Storage</a>, and this continual verification process is part of the service they provide. Both services store multiple copies of each file, and they use checksums to ensure file integrity. If they ever detect corruption in one copy, they repair it using one of the other copies.</p><p>Both services are certified for compliance with a variety of international, independent standards for information security (<a href="https://aws.amazon.com/compliance/">AWS</a>, <a href="https://azure.microsoft.com/en-us/resources/microsoft-azure-compliance-offerings/">Azure</a>). The level of data integrity and safety they provide goes far beyond anything we could build in-house. We trust their verification process, and don’t do any additional checking of data at rest.</p><h3>How we verify</h3><p><strong>Every check I’ve described happens automatically. </strong>These checks form part of the automated storage service that stores new files in our digital archive. This means they always happen reliably and consistently, and don’t rely on manual intervention or somebody remembering to do the checks. It also gives staff more time to work on other tasks that can’t be automated, like writing catalogue descriptions or appraising a new collection.</p><p>In fact, humans aren’t even allowed to write directly to the underlying storage — they have to go through the storage service. This gives us a very high degree of confidence in the integrity of the archive, because we know everything has been through a rigorous set of checks and verifications.</p><p>When we write new checks, we make sure to write a good user-facing error message. If the storage service does reject some files, we want it to explain why they were rejected and how they can be fixed. Ideally, these messages should make sense to somebody who isn’t a developer, or who doesn’t understand the inner workings of the storage service.</p><p><strong>A digital archive doesn’t just run on computers, it runs on trust. People should trust that it’s a safe and secure store for our digital collections.</strong></p><p><strong>Having a robust verification process helps build that trust. It shows that the archive will ensure the integrity of the files it contains, and can act as a suitable long-term store for our files.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79da59da4ab7" width="1" height="1" alt=""><hr><p><a href="https://stacks.wellcomecollection.org/our-approach-to-digital-verification-79da59da4ab7">Our approach to digital verification</a> was originally published in <a href="https://stacks.wellcomecollection.org/">Stacks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A sprinkling of Azure]]></title>
            <link>https://stacks.wellcomecollection.org/a-sprinkling-of-azure-6cef6e150fb2?source=rss-e34c74a2c5d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6cef6e150fb2</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[digital-preservation]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[cloud-storage]]></category>
            <dc:creator><![CDATA[Alex Chan]]></dc:creator>
            <pubDate>Wed, 30 Sep 2020 12:22:00 GMT</pubDate>
            <atom:updated>2020-09-30T12:57:47.376Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Our cloud storage service is designed to ensure the <a href="https://stacks.wellcomecollection.org/building-wellcome-collections-new-archival-storage-service-3f68ff21927e#5bf4">long-term preservation</a> of our digital collections. As an archive, we have an obligation to ourselves and to our depositors to keep our collections safe. We’ve spent millions of pounds digitising our physical objects, and some of our born-digital and audiovisual material is irreplaceable.</p><p>One way we do this is by storing multiple copies of every file. If one copy were to be corrupted or deleted, we’d still have other copies that we could use to construct the complete archive.</p><p>In the initial iteration of our storage service, we kept two copies of every file in a pair of Amazon S3 buckets. We’ve recently upgraded the storage service to keep a third copy of every file in Azure Blob Storage, and in a different geographic location. In this post, I’m going to explain why this change was important, and how we made it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hzlrKdGY5T6LFShpE9DvMg.jpeg" /><figcaption>Photo by Marco Almbauer, taken from <a href="https://commons.wikimedia.org/wiki/File:Azurblau_Pigment.JPG">Wikimedia Commons</a>, used under CC BY-SA 3.0.</figcaption></figure><h3>Why do we need another storage provider?</h3><p>Before we started this work, both copies of our digital collections were kept in two S3 buckets. Both buckets are in the same AWS account.</p><p><strong>Our AWS account is a single point of failure. </strong>Although Amazon invest heavily in reliability and durability — for example, objects in S3 are stored across <a href="https://aws.amazon.com/s3/faqs/#AWS_Regions">multiple, distinct facilities (“Availability Zones”)</a> and should survive the destruction of a single data centre — you can imagine scenarios in which we lose everything in our S3 buckets.</p><p>Amazon could close our account because of a payment issue. Somebody could accidentally run a script that empties both buckets. There could be a systemic issue that affects all content in S3.</p><p><strong>Adding a second provider removes this single point of failure. </strong>All of these scenarios could still happen, but another copy of the data in a separate provider means they would be inconvenient rather than disastrous. There are fewer scenarios that would affect multiple providers simultaneously.</p><h3>Why do we need another geographic location?</h3><p>All of our data in S3 is kept in a single <a href="https://aws.amazon.com/about-aws/global-infrastructure/regions_az/">AWS region</a>. An AWS region is a collection of data centres in the same geographic area. We use the eu-west-1 region, which means our data is somewhere in Ireland.</p><p><strong>Having all our data in the same geographic location is another single point of failure. </strong>Although our data is spread across multiple data centres, you can imagine manmade or natural disasters in which many data centres are affected at the same time.</p><p><strong>Adding a second geographic location removes this single point of failure. </strong>There are fewer disasters that would affect multiple locations at once, especially if (as our replicas are) the locations are on different landmasses.</p><h3>Which location and provider did we choose?</h3><p>We chose Azure Blob Storage because Wellcome is already using Azure for a number of other services, including Active Directory and SQL Databases — but the account is owned and managed by a different team. That means the account has a different payment setup, different support contacts, and a different authentication system. Even the internal processes for getting access to our AWS and Azure accounts are different.</p><p><strong>There’s very little overlap between our AWS and Azure accounts, which minimises the chance of a systemic failure that affects both. </strong>That overlap includes people. At time of writing, just three people have access to all three replicas, and eventually we’d like to reduce that number. That means there are very few people who could wipe out every copy of the archive (whether accidentally or maliciously.)</p><p>We did look at other cloud storage providers — there are plenty of good choices, all of which would probably have worked similarly well. Azure was the best choice for us, but it may not be for you. <strong>If you have critical data in cloud storage, the important thing is to have a backup in another cloud. Which cloud you use as backup is less important.</strong></p><p>We’re using Azure’s West Europe (Netherlands) region. We chose it because it’s a good distance from Ireland, and roughly equidistant from the Wellcome Collection building. Again, the exact choice isn’t so important — the important thing is that it’s a different geographic location from our data in S3.</p><h3>How did we implement replication to Azure?</h3><p>We reused <a href="https://stacks.wellcomecollection.org/building-wellcome-collections-new-archival-storage-service-3f68ff21927e#66a9">the design we have for storing files in S3</a>. The unit of storage in our digital archive is <a href="https://tools.ietf.org/html/rfc8493">a BagIt “bag”</a>, and each bag is passed through a series of applications. Each application does one step in the process of storing a bag — unpacking a compressed archive, verifying the bag’s contents, copying the bag to long-term storage, and so on.</p><p>We had to create new versions of our applications that could manage bags in Azure Blob Storage:</p><ul><li>The <em>bag replicator </em>copies a bag from working storage (in S3) to permanent storage (in S3 or Azure). Previously our replicator could only write bags to S3; we had to extend it to write bags into Azure Blob Storage.</li><li>A BagIt “bag” includes a file manifest, with a checksum for every file in the bag. The <em>bag verifier </em>compares the stored bag to the checksums in the manifest, to confirm the bag was written correctly. We had to build a new verifier that could inspect bags in Azure.</li><li>The <em>replica aggregator</em> counts the number of verified copies of a bag, and warns us if a bag doesn’t have enough copies. Previously it only counted two replicas, now it has to count three.</li></ul><p>We built prototypes of these new apps, and then we added them to the pipeline for new bags. That meant that any new bags that were stored were being written to S3 and Azure, but all the existing bags were only stored in S3. We left this running for a few weeks to see how our new code worked with real bags.</p><p>Once we were confident these new apps were working, we replicated all of our existing bags into Azure. That took several weeks, after which our Azure storage account was byte-for-byte identical to our existing S3 buckets. As we were doing it, we kept tweaking the apps to handle unusual bags and improve reliability.</p><h3>What was hard?</h3><p>There were a number of challenges writing bags to Azure.</p><h4>Getting used to Azure</h4><p>Until now, the Platform team has worked entirely in AWS. Although S3 and Blob Storage are similar (they’re both distributed object stores), they differ in the details, and it took us time to get used to the ins and outs of Azure Blob Storage.</p><p>This is especially important when things go wrong. We have plenty of experience with the edge cases of S3, and the storage service has code to handle and retry unusual errors. We don’t have that experience with Azure, and we had to learn very quickly.</p><h4>Refactoring our code to work with Azure</h4><p>We’ve known we wanted to add another storage provider since the earliest designs of the storage service, and we tried to write our code in a <a href="https://alexwlchan.net/2019/10/sans-io-programming/">sans I/O</a>, provider-agnostic way. For example, the code that parses a BagIt “bag” manifest shouldn’t have to care whether the bag is in S3 or Blob Storage.</p><p>In practice, there were still plenty of cases where our code assumed that it would only ever talk to S3. We had to do a lot of refactoring to remove these assumptions before we could start adding Azure support.</p><p>Although we have no immediate plans to do so, doing this work once should make it easier to add another provider in the future. The hard part was making our code truly generic enough to handle more than one provider; after that, adding additional providers should be simpler.</p><h4>The cost of cross-cloud data transfer</h4><p>Copying your data into a public cloud is free — but if you want to get it out again, you have to pay. Copying a gigabyte of data out of S3 costs as much as storing it for nearly <em>four months</em>.</p><p>Our complete data transfer cost was about $10k for our 60TB archive— not eye-wateringly expensive, but enough that we didn’t want to do it more than necessary. (We paid once to replicate everything from S3 to Azure, and once for the verifier running in AWS to read everything from Azure to check we wrote the correct bytes.)</p><p>We took several steps to keep our data transfer costs down, including caching the results of the Azure bag verifier, and <a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_NAT_Instance.html">running our own NAT instances</a> in AWS to avoid the bandwidth cost of Amazon’s <a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html">managed NAT Gateway</a>.</p><h4>Reading and writing large files</h4><p>Some of the files we have are fairly large — the largest we’ve seen so far is 166GiB, which is a preservation copy of a digitised video.</p><p>Trying to read or write such a large file in a single request can be risky. You need to hold open the same connection for a long time, and if anything goes wrong (say, a timeout or a dropped connection), you have to start from scratch. It’s generally more reliable to break a large file into smaller pieces, read or write each piece individually, then stitch the pieces back together. Both AWS and Azure encourage this approach and have limits on how much data you can write in a single piece.</p><p>We’ve had to write a lot of code so that we can reliably read and write blobs of all sizes — with our initial prototypes, we saw dropped connections and timeouts when working with larger blobs. Some of this was adapting code <a href="https://alexwlchan.net/2019/09/streaming-large-s3-objects/">we’d already written for S3</a>; some of it was entirely new code for Azure.</p><p>This is an area where the S3 SDK is more mature than Azure. The S3 Java SDK provides the <a href="https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/transfer/TransferManager.html">TransferManager class</a> for uploading large files, which handles the details of breaking the file into smaller pieces. The Azure Java SDK doesn’t provide a comparable class — we had to write and debug our own code for uploading large files. We’re surely not the first people to need this functionality, and it would be nice if it was provided in the SDK.</p><h3>Where we are now</h3><p>Every bag in the storage service has three copies: one in Amazon S3, one in Amazon Glacier, one in Azure Blob Storage. When we store new bags, they’re copied to each of these locations.</p><p>This means our digital archive is much more resilient and less likely to suffer catastrophic data loss. This gives us more confidence as we continue to build on it and use it for ever-more data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6cef6e150fb2" width="1" height="1" alt=""><hr><p><a href="https://stacks.wellcomecollection.org/a-sprinkling-of-azure-6cef6e150fb2">A sprinkling of Azure</a> was originally published in <a href="https://stacks.wellcomecollection.org/">Stacks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Large Things Living in Cold Places]]></title>
            <link>https://stacks.wellcomecollection.org/large-things-living-in-cold-places-66cbc3603e14?source=rss-e34c74a2c5d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/66cbc3603e14</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[digital-preservation]]></category>
            <category><![CDATA[cloud-pricing]]></category>
            <category><![CDATA[cloud-storage]]></category>
            <dc:creator><![CDATA[Alex Chan]]></dc:creator>
            <pubDate>Wed, 17 Jun 2020 09:31:24 GMT</pubDate>
            <atom:updated>2020-06-17T19:01:38.764Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MUENzYu_DqEnOD7e39HVrw.jpeg" /><figcaption>A group of developers set off on an expedition to find the objects stored in Glacier. Colour lithograph by J. Arnout, 1843, <a href="https://wellcomecollection.org/works/v797vg8b">Wellcome Collection</a>. CC BY.</figcaption></figure><p>In <a href="https://stacks.wellcomecollection.org/building-wellcome-collections-new-archival-storage-service-3f68ff21927e">our digital archive</a>, we store everything in cloud storage. One advantage of cloud storage is that capacity becomes a non-issue — our cloud provider has to worry about buying disks or installing hardware, not us. We upload new files and our bill goes up, but we’ll never run out of disk space.</p><p>This is especially useful for one of our current projects, which is the digitisation of our A/V material. We’re trying to digitise all our magnetic media before it becomes unplayable — either because the media itself degrades, or because there are no more working players.</p><p>We make two copies of every piece of A/V:</p><ul><li>An <em>access copy</em>: a file that we use to create derivatives suitable for viewing on our website.</li><li>A <em>preservation copy</em>: a file for long-term storage. This is a lossless format with a higher bitrate and resolution than the access copy. We can use it to create new copies if our preferred video formats change, or in cases where we need the highest quality possible.</li></ul><p>The preservation copies are <em>big</em> — the biggest so far is 166GB from a single video, and there may be bigger ones to come. We estimate the project is going to triple the amount of data we have in the archive.</p><p>Because cloud storage is effectively unlimited, that rough estimate is fine — we don’t need to pre-buy the exact amount of storage we need. But tripling the amount of data means tripling our monthly storage bill. Oof. <strong>Can we do something about that?</strong></p><p>How much you pay for cloud storage depends on three things:</p><ul><li><em>How much stuff do you have? </em>Storing more stuff costs more money.</li><li><em>How much redundancy do you want? </em>It’s cheap to keep one copy of your files, but you’re a single failure away from data loss. If you want better protection, you can store additional copies in different locations, but those extra copies cost more money.</li><li><em>How quickly do you need to get stuff out? </em>If you need to be able to retrieve things immediately, it’s quite expensive. If you’re willing to wait, your files can be pushed into cheaper storage that’s slower to access.</li></ul><p>You choose how much redundancy and access you want by selecting a <em>storage class</em>. Each class has a fixed price per GB stored, and that price is smaller for classes with less redundancy or slower access. That gives predictable, linear pricing within a storage class: store twice as much stuff, pay twice as much.</p><p>We can’t store less stuff or compromise on redundancy — but we don’t need to get these large preservation copies out very often. They’re not served directly to website users, so we can accept a small delay in retrieving them. <strong>We can store our preservation copies in a cold storage class with slower access, and save some money.</strong></p><p>This isn’t a new idea — we do the same thing for physical material. Some of our books and archives are kept on-site in London, and the rest are kept in <a href="http://www.deepstore.com/">an underground salt mine</a>. There’s a delay to retrieve something from the mine — among other things, it’s a nearly 200 mile drive — but space in Cheshire is cheaper than central London. Different material is stored in different ways.</p><p>The primary copy of all our data is in Amazon S3. At the time of writing, S3 has <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html">seven storage classes</a>, with two of them cold: <em>Glacier</em> and <em>Deep Archive. </em>They’re both significantly cheaper than the standard class, and typically take several hours to retrieve a file. One difference is that Glacier has <a href="https://aws.amazon.com/about-aws/whats-new/2016/11/access-your-amazon-glacier-data-in-minutes-with-new-retrieval-options/"><em>expedited retrievals</em></a> — if you need something quickly, you can retrieve it in minutes, not hours.</p><p>We will need expedited retrieval on occasion, so we picked Glacier over Deep Archive. We’ve already used Glacier to store high-resolution masters from our photography workflow — and yes, we do restore files sometimes! — so on balance, the extra cost over Deep Archive is worth it.</p><p>(We use Deep Archive elsewhere — for a second, backup copy of all our data.)</p><p><strong>We store the primary copy of our large preservation files in Glacier to reduce our storage costs.</strong></p><p>One of our priorities for our digital archive is human-readability: it should be possible for a person to understand how the files are organised, even if they don’t have any of our software or databases. The preservation and access copies are the same conceptual object, so we want to group them together within the archive — ideally in the same folder/prefix.</p><p>Within S3, the storage class is managed at the per-object level — you can have objects with different storage classes within the same bucket or prefix. This means we can keep the preservation and access copies together.</p><p>This is what a digitised A/V item looks like in our storage buckets:</p><pre>b12345678/<br> ├── METS.xml          (metadata file)<br> ├── b12345678.mp4     (access copy, warm storage - Standard IA)<br> └── b12345678.mxf     (preservation copy, cold storage – Glacier)</pre><p>So how do we tell S3 which objects should go in which storage class?</p><p>We’ve created an app that watches files being written to the storage service. When it sees a new preservation file, it adds a tag to the corresponding object in S3. (<a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/object-tagging.html">Tags</a> are key-value pairs that you can attach to individual objects.)</p><p>Then we have <a href="https://docs.aws.amazon.com/AmazonS3/latest/user-guide/create-lifecycle.html">an S3 lifecycle policy</a> that automatically moves objects with certain tags to Glacier. (We don’t write objects straight to Glacier — immediately after we write an object, we read it back out to verify it against an externally-provided checksum. If we wrote straight to Glacier, we’d be unable to perform this verification step.)</p><p>All the pieces of this system are now up and running, and it’s going to be a substantial cost saving as we start to bring in our digitised A/V material:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yiQSoTDnUUndwKM806VzNA.png" /><figcaption>We spent about a month adding Glacier support to the storage service, so the 100TB of A/V material we’re about to ingest will pay for this work within a year or so.</figcaption></figure><p>We can do this because we have a clear understanding of how our files are used and retrieved, and a few simple rules give us a noticeable saving. <strong>If you have a big storage bill and you want to make it smaller, understanding how your files are used is often a good place to start. </strong>Whatever cloud storage provider you’re using, you can often save money by selecting a storage class that’s appropriate to your use case.</p><p><em>Thanks to Harkiran Dhindsa, Jonathan Tweed, Sarah Bird, and Tom Scott for their help writing this article.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66cbc3603e14" width="1" height="1" alt=""><hr><p><a href="https://stacks.wellcomecollection.org/large-things-living-in-cold-places-66cbc3603e14">Large Things Living in Cold Places</a> was originally published in <a href="https://stacks.wellcomecollection.org/">Stacks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we store multiple versions of BagIt bags]]></title>
            <link>https://stacks.wellcomecollection.org/how-we-store-multiple-versions-of-bagit-bags-e68499815184?source=rss-e34c74a2c5d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/e68499815184</guid>
            <category><![CDATA[digitization]]></category>
            <category><![CDATA[libraries]]></category>
            <category><![CDATA[digital-preservation]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Alex Chan]]></dc:creator>
            <pubDate>Tue, 11 Feb 2020 13:00:26 GMT</pubDate>
            <atom:updated>2020-02-11T13:00:26.569Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h4>We made fetch.txt happen.</h4><p>In <a href="https://stacks.wellcomecollection.org/building-wellcome-collections-new-archival-storage-service-3f68ff21927e">my last post</a>, I talked about the general ideas behind our new archival storage service.</p><p>A brief reminder: we store our digital archive in BagIt “bags”. A bag is a collection of related files: for example, all the digitised images from a single book. BagIt is <a href="https://tools.ietf.org/html/rfc8493">an open format</a> developed by the Library of Congress for packaging files, which includes manifests and checksums that describe the files in a bag — so we can verify files have been transferred and stored successfully. The bags we store are produced by our workflow systems: Goobi for digitised material, Archivematica for born-digital material.</p><p>In the post, I had an illustration showing how we store files on disk in a human-readable way, including the fact that we can store multiple versions of a bag. The BagIt spec doesn’t include a system for versioning — we had to design our own approach — and several people asked how it works.</p><p>In this post, I’m going to explain the versioning of the storage service in more detail. We have an elegant system based on the fetch.txt feature of the BagIt spec.</p><p><em>Author’s note: my previous post was a general overview; this post focuses on a more specific implementation detail. I enjoy this sort of deep dive, but it may not be for everyone. At the very least, grab a warm drink and a biscuit before you start. Treat yourself.</em></p><h3>The problem</h3><p>The storage service allows us to store a collection of files as a single bag. Sometimes we want to change a bag after it was initially stored. For example, we might be editing the metadata, or fixing the incorrect rotation of an image.</p><p>We want to record these changes, but also to preserve the provenance of the original files. Whatever mechanism we came up with for storing updates had to preserve the older versions.</p><p>We came up with the following requirements:</p><h4>You can get back any version, not just the latest one</h4><p>If you store a bag (call that “version 1”) and then later store an updated bag (“version 2”), you should be able to request either version 1 or version 2, and get back the corresponding files.</p><h4><strong>You can request the latest version of a bag</strong></h4><p>Although storing multiple versions of a bag is important for historical provenance, the distinction doesn’t matter to every user. It should be possible to get the latest version without having to know how many other versions have been stored.</p><h4><strong>We can find the version of a bag at a specific time</strong></h4><p>Suppose somebody downloaded the latest version of a bag at a particular time, but didn’t take note of the version. We should be able to work out which version of the bag they were looking at.</p><h4><strong>Versions should make sense to people</strong></h4><p>If you have a list of all the versions of a bag, it should be obvious which is the latest version, and what order the versions were stored in.</p><p>For example, if I tell you the versions are “v1”, “v2” and “v3”, you can tell that’s the order they were stored in. Compare to something like <a href="https://en.wikipedia.org/wiki/Git">the version-control system Git</a>, which identifies changes with SHA-1 hashes. Is 7faf7ef<em> </em>newer than 6fe2b1f? Unless you can understand the Git database, it’s impossible to say.</p><h3>Technical requirements</h3><p>The requirements above describe how the system should behave; we also had some requirements based on how we’d implemented the rest of the storage service:</p><h4>The versions should be laid out in a human-readable way on disk</h4><p>We know these files have to last a long time, so the versioning scheme should be clear from the structure of the files on disk. Everything I described above (get back any version, get the latest version, work out the ordering) should be possible with nothing but the file layout.</p><p>Further, it should be clear that this is a versioning system. You should be able to tell, say, that <em>b1234/v1 </em>and <em>b1234/v2</em> are two versions of the same bag, not two different bags.</p><h4>We should support partial updates</h4><p>Suppose v1 of a bag contains 1000 files, and we want to update a single file. When we record the update, it should be possible to store just the updated file, and not keep extra copies of all the unchanged files.</p><h4>Once a version is written, it’s immutable</h4><p>If we’ve stored and verified v1, trying to store v2 shouldn’t compromise the integrity of the v1 bag.</p><p>We don’t want to overwrite an already-stored bag. This introduces lots of complexity and potential for error: what if you try to store an update, the update fails, and then you roll back to the previous version and that fails also? You’ve broken the integrity of your archive. If new versions are strictly additive, and never affect previously-stored files, we avoid this failure mode.</p><h3>The solution</h3><p>The idea of storing partial updates helped us find the first part of the solution: using the <a href="https://tools.ietf.org/html/rfc8493#section-2.2.3">fetch.txt in a BagIt package</a>.</p><p>The fetch.txt is a mapping of files paths in the bag to URLs. It tells the person reading the bag that a file hasn’t been included in this copy of the bag; they have to go and fetch it from elsewhere. The file is still recorded in the manifest (so it has a checksum you can verify), but you don’t have a complete bag until you’ve downloaded all the files.</p><p>Here’s an example of a fetch.txt:</p><pre>https://example.org/~lexie/report.pdf  1729  data/report.pdf</pre><p>This tell us that the file data/report.pdf isn’t included in this copy of the bag — we should download it from https://example.org/~lexie/report.pdf. (The number 1729 is the size of the remote file. It’s an optional field.)</p><p>Using a fetch.txt allows you to send a bag with “holes”, which saves disk space and network bandwidth, but at a cost — we’re now relying on the remote location to remain available. From a preservation standpoint, this is scary! If example.org went away, this bag would be broken. I know some people don’t use fetch.txt in their digital archives for exactly this reason.</p><p>But a URL can point anywhere — including back into our storage service. Because the primary copy of our files is in S3, we can construct a fetch.txt with an S3 URL. For example:</p><pre>s3://wellcomecollection-storage/examples/lexie/v1/data/report.pdf  1729  report.pdf</pre><p>So we added a rule: <strong>you can include a fetch.txt, but it can only refer to files within the storage service.</strong></p><p>Later, we strengthened the rule: <strong>a fetch.txt can only refer to files in previous versions of the same bag.</strong></p><p>The first rule means the archive is self-contained, and we’re not relying on the long-term availability of other systems to maintain the archive’s integrity. The second rule keeps it simple: you can only have back-references within a single bag, not among all bags. This avoids a twisted mess of spaghetti references!</p><h4>An aside: what is “the same bag”?</h4><p>I’ve talked about keeping multiple versions of “the same bag”, but what does that look like in practice? How does the storage service distinguish between two versions of the same bag, or two different bags with one version each?</p><p>A BagIt bag can include <a href="https://tools.ietf.org/html/rfc8493#section-2.2.2">a metadata file bag-info.txt</a>. One of the fields in this file is <em>External-Identifier</em>, which is “a sender-supplied identifier for the bag”. Although External-Identifier is optional in the BagIt spec, our storage service requires that you give a value here: for example, an identifier from our library catalogue. Bags are then grouped based on their external identifier.</p><p>If two bags have the same external identifier, we treat them as two versions of the same bag. If two bags have different external identifiers, we treat as two different bags with one version each.</p><h4>Laying out different versions of a bag on disk</h4><p>An identifier in the storage service is made of three parts:</p><ul><li>The <em>storage space</em>, e.g. “digitised” or “born-digital”. This is the broad category of a bag.</li><li>The <em>external identifier</em>, as supplied in the bag-info.txt. This is usually the identifier from another system.</li><li>The <em>version</em>, which is generated by the storage service. It’s an auto-incrementing value: v1, v2, v3, and so on.</li></ul><p>The path to a bag is constructed as follows:</p><pre>{space}/{external identifier}/{version}</pre><p>For example, if we had three versions of a bag in the “digitised” space with external identifier “b31497652”, we’d have the following folder structure:</p><pre>digitised/<br>  └── b31497652/<br>        ├── v1/<br>        ├── v2/<br>        └── v3/</pre><p>All the versions for a given (space, external identifier) are under the same folder. We chose to add a “v” prefix to make it more obvious that the folders correspond to versions; an earlier design used numerals alone.</p><h3>A worked example</h3><p>The best way to understand how the versioning behaves is to see a few examples. Let’s see how you might update a bag.</p><p>When you store the <strong>first version of a bag</strong>, you have to include all the files. Let’s create a bag with two files: <em>cat.jpg</em> and <em>dog.jpg</em>. The bag manifest file has two entries, and there is no fetch.txt file. This bag is stored as <strong>v1</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*zr2N5-4DTHKqAvv8qzoGDg.png" /></figure><p>Now we want to <strong>add a new file</strong>. Suppose we want to add <em>fish.jpg</em>.</p><p>We could upload a complete copy of the bag again, or we could upload a <em>partial update</em>. This bag includes a manifest with three entries (<em>cat.jpg</em>, <em>dog.jpg</em>, <em>fish.jpg</em>), a fetch.txt with two entries (<em>cat.jpg</em> in v1, <em>dog.jpg</em> in v1), and a copy of the new image. This bag is stored <strong>v2</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*9jqa-5K6rPpQ9ID4T0oatA.png" /></figure><p>Next, suppose we want to <strong>delete</strong> <strong>a file</strong>. Maybe <em>dog.jpg</em><strong> </strong>doesn’t really belong in this bag, and we’d like to remove it.</p><p>We create a bag with a manifest file with two entries (<em>cat.jpg</em>, <em>fish.jpg</em>) and a fetch.txt with two entries that point back to previous versions. There’s no reference to <em>dog.jpg</em> anywhere in this bag. This becomes <strong>v3</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*Oh5Iv3S3Od4w7PC1f7ndLg.png" /></figure><p>The <em>dog.jpg </em>file is still available in v2, but it’s not referenced in v3 so it’s not part of that version of the bag.</p><p>Finally, suppose we want to <strong>modify a file</strong>. Maybe we have a new, cuter picture of <em>cat.jpg</em>.</p><p>We create a fourth bag. The manifest has two entries, the fetch.txt has a single entry (pointing back to the unmodified copy of <em>fish.jpg</em>), and the bag has the new copy of <em>cat.jpg</em>. This becomes <strong>v4:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*D2ag4rgpwUHz7wGXLwFEtA.png" /></figure><p>We’ve now stored four versions of this bag, and we could retrieve a complete copy of any version — but we’ve only had to store four files, not nine.</p><p>In practice, bags contain hundreds or thousands of files, so there are significant storage savings if we do partial updates.</p><p>If you want to do a more complex update (for example, adding some new files and updating some others), you can combine these operations to construct the appropriate bag.</p><p>Each of these versions has been through the same verification process:</p><ul><li>We check the checksums in the manifest match the actual files, whether the file is included in the uploaded bag, or stored in a previous version and referenced in the fetch.txt.</li><li>If the entry in the fetch.txt includes the size of the file, we check the size matches.</li><li>We check that every URL in the fetch.txt only refers to previous versions of the same bag. Anything else — an HTTP link, an FTP URI, a file in a bag with a different external identifier — gets rejected.</li></ul><h3>What about automatic deduplication?</h3><p>To get any savings in storage cost, you need to de-duplicate identical files between different versions, like we’re doing with fetch.txt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*jw3Yc8Qm7EGQRcc5SuR5fQ.png" /><figcaption>Now imagine trying to unpick this, but for seventy million files, not seven.</figcaption></figure><p>To maximise your savings, you’d automatically deduplicate <em>any</em> files that get stored. Some systems do this — for example, Git stores files based on their SHA-1 hash of their content. If you save the same file multiple times, it only saves a single copy. This is more efficient for storage, but Git has to maintain a set of pointers between the original filenames and the SHA-1 hashes, which breaks the idea that our files should be stored in a clear, human-understandable way. (If you’re interested in how Git stores files internally, you might enjoy my <a href="https://alexwlchan.net/a-plumbers-guide-to-git/">Plumber’s Guide to Git</a>.)</p><p>We could identify duplicate files in previous versions, and create an appropriate fetch.txt ourselves, but this would be more complicated. The storage service is deliberately simple — simple code is easier to implement, has less room for bugs, and less risk of accidental data loss or corruption.</p><p><strong>We chose not to automatically deduplicate files in the storage service. </strong>We rely on the user to tell us about duplicate files by uploading an appropriate fetch.txt. If they upload duplicate files without a fetch.txt, we’ll just store all the files a second time. Although this is slightly less efficient, it reduces the risk of corruption or error.</p><p>The storage service has a simple rule: <strong>it stores exactly what bytes you provide; no more, no less</strong>. If you supply a concrete copy of the same file in multiple versions, we’ll store a concrete copy of that file in every version.</p><p>This also allows for easier external verification. If you upload a bag to the storage service, you can download your bag later and check the bytes are exactly what you uploaded. If the service started editing your files, that sort of verification would be much harder.</p><h3>A BagIt alternative with first-class versioning: OCFL</h3><p>Our storage service is based heavily on the BagIt format. BagIt doesn’t have built-in support for versioning — what I’ve described is a convention we created, not part of the spec.</p><p>Since then, there have been several draft specifications for the <a href="https://ocfl.io/"><em>Oxford Common File Layout (OCFL)</em></a>, another convention for storing digital files in a structured, human-readable way. Unlike BagIt, OCFL has first-class support for versioning as part of the spec. The folder layout for versions is similar to our design. (I can’t remember if this was a simultaneous invention, or if we’d read the OCFL draft spec when we designed our system.)</p><p>If you’re interested in versioning your archive, it’s worth considering the ideas in the OCFL spec.</p><p>This solution arose organically, because we could iterate quickly on our original prototype. Rather than designing the whole system upfront, we could experiment with different approaches — at least half a dozen designs, probably more.</p><p>Using fetch.txt to handle BagIt versions gives us simple, human-readable versioning for bags. We can look up any version, use partial updates to reduce storage costs, and the archive is always self-contained. Since we started using the storage service last October, we already have over 1500 bags stored with multiple versions, and that number will only grow.</p><p><em>Thanks to Robert Kenny, Jamie Parkinson, and Tom Scott for their help writing this post.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e68499815184" width="1" height="1" alt=""><hr><p><a href="https://stacks.wellcomecollection.org/how-we-store-multiple-versions-of-bagit-bags-e68499815184">How we store multiple versions of BagIt bags</a> was originally published in <a href="https://stacks.wellcomecollection.org/">Stacks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Wellcome Collection’s new archival storage service]]></title>
            <link>https://stacks.wellcomecollection.org/building-wellcome-collections-new-archival-storage-service-3f68ff21927e?source=rss-e34c74a2c5d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f68ff21927e</guid>
            <category><![CDATA[strategy]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[digital-transformation]]></category>
            <category><![CDATA[museums]]></category>
            <category><![CDATA[digitization]]></category>
            <dc:creator><![CDATA[Alex Chan]]></dc:creator>
            <pubDate>Wed, 05 Feb 2020 11:05:37 GMT</pubDate>
            <atom:updated>2020-02-05T22:07:39.872Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>For the last year or so, we’ve been building a cloud-based storage service to hold Wellcome Collection’s ever-growing digital archive. This is a brand new system, designed to cope with our storage needs both now and into the future.</p><p>In this post, I’m going to explain how we built the new service, and how we migrated our existing archive from our old storage provider.</p><figure><img alt="CDs at an oblique angle, with multi-coloured light shining off their reflective surfaces." src="https://cdn-images-1.medium.com/max/1024/1*uZDTbW6FpQQT4wZvUfg3Iw.png" /><figcaption>When choosing a storage format, it’s important to pick something that looks cool in technicolour lighting. Photo by Paul Griggs. Used under <a href="https://wellcomecollection.org/works/bc7ycmrz">CC BY</a>.</figcaption></figure><h3>Why do we need a storage service?</h3><p>Before I explain how we built the new service, it’s worth explaining why we need one at all.</p><p>Alongside our physical catalogue, we hold a substantial number of digital collections. These include:</p><ul><li><a href="https://en.wikipedia.org/wiki/Born-digital"><em>Born-digital material</em></a>: files that started life as digital objects, say an Excel spreadsheet or an email; and</li><li><a href="https://en.wikipedia.org/wiki/Digitization"><em>Digitised material</em></a>: digital reproductions of physical objects, like a scanned pamphlet or a photographed book.</li></ul><h4>To ensure access to our material</h4><p>Wellcome’s mission is to improve human health by enabling great ideas to thrive. One way we do that is by holding and providing access to collections about the history of human health and medicine.</p><p>We want to provide access to as many and as wide a range of people as possible, and digital access is central to that goal. We need a storage service that keeps our collections safe and enables access to researchers, now and in the future.</p><h4>To preserve our material in the long-term</h4><p>We have an obligation as an archive and to our depositors to keep our collections safe. We can’t just throw these files on a hard drive, and hope for the best — disks fail, files get corrupted, the software to read file formats goes away. Unlike paper books, which degrade slowly and remain readable for decades, computers and their files become unusable within a matter of years.</p><p>If the digital archive was lost, many of the files are irreplaceable. In some cases, our born-digital and audiovisual files are the only remaining copy.</p><p>Audiovisual material is especially sensitive to loss: the medium of the original copy can degrade, whereas a digital file is lossless if stored safely. One of our current major projects is the digitisation of all our magnetic media — VHS tapes, Betamax, audio cassettes, and so on — before those recordings become unreadable forever.</p><p>If we want to preserve these collections, we need a storage service that can keep these files safe. That means <a href="https://en.wikipedia.org/wiki/Defense_in_depth_(computing)">multiple levels of protection</a>, including checksums to ensure file integrity, backup copies of every file, and continually checking files to spot corruption.</p><h4>To protect our investment</h4><p>We have invested significantly in digitising our collections over the last decade. We have a responsibility to protect that investment.</p><h3>Why did we build our own storage service?</h3><p>There are a couple of reasons why we built our own storage service, rather than using an existing solution:</p><h4>Clear ownership of the archive</h4><p>When you think about archives, you have to think in the long-term. We’re not saving files for weeks or months, we’re preserving them for <em>centuries</em>.</p><p>We want to be sure that the files are being kept securely, and having ownership over the archive, the code and the APIs gives us a lot of control. By building a storage service ourselves, we know exactly how and where the files are stored, and what checks are in place to ensure the files are safe.</p><p>When we were building the new service, a key focus was building something as portable and understandable as possible. <strong>The files themselves will likely outlive any particular software stack, so we want to organise them in a way that remains useful long after all our code is gone.</strong></p><h4>A more human-readable storage layout</h4><p>A lot of storage tools use <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUIDs</a> as their identifiers in their underlying storage. If you look at the files on disk, you see a pile of opaque filenames:</p><figure><img alt="A folder hierarchy with a top folder “archive”, and under it four files labelled with UUIDs." src="https://cdn-images-1.medium.com/max/1024/1*sZYDsDSJnri5vMb8TRM9wQ.png" /></figure><p>To understand the archive, you need a mapping between the UUIDs and the original filenames, which is often kept in a proprietary database. This means you’re tied to that provider, and migrating away is expensive. And if the database is lost, your archive is unusable.</p><p>When we designed our new storage service, we emphasised human-readable paths and identifiers from our existing catalogues. The files are laid out on disk in a more understandable way—you can find things in the archive from just the underlying file storage. Here’s what it looks like:</p><figure><img alt="A file hierarchy “digitised/b31497652/v1”. Under “v1” there are files “bagit.txt”, “bag-info.txt”, “data/b31497652_01.jp2”." src="https://cdn-images-1.medium.com/max/1024/1*vZOnqZSwBgpJ_1M-bacBuQ.png" /><figcaption>The bagit.txt and bag-info.txt are part of the <a href="https://tools.ietf.org/html/rfc8493">BagIt packaging format</a>. The folder name “b31497652” is an identifier from Sierra, our library management software. We can store multiple versions of a bag — for example, if the metadata has been edited or a file replaced.</figcaption></figure><p>Being able to find things is important for long-term portability and understandability.</p><h4>A preference for open source and open standards</h4><p>We prefer using or writing open source software where possible, and building on open standards.</p><p>Using open standards allows us to use other tooling when working with the archive. For example, packages in the archive are kept in the <a href="https://tools.ietf.org/html/rfc8493">BagIt packaging format</a>. Lots of tools know how to understand BagIt bags, and you could use them to independently verify the files that we’re holding.</p><p>This also helps the longevity of the archive. Because we use open standards and the code is open source, it’s more likely that tools will continue to exist that can work with the archive.</p><p>Finally, developing in the open allows other people to benefit from our work. All the code we’ve written for the storage service is in <a href="https://github.com/wellcometrust/storage-service">a public GitHub repo</a>, and available under an MIT license.</p><h3>How did we build the storage service?</h3><p>We started by coming up with a high-level design for the service.</p><figure><img alt="Pipeline diagram. BagIt bag (white) ~&gt; Storage service (blue) ~&gt; two S3 buckets (red)." src="https://cdn-images-1.medium.com/max/1024/1*GJsWfxHnXjZVqmwErpKF3w.jpeg" /></figure><p>The user uploads packages in the <a href="https://tools.ietf.org/html/rfc8493">BagIt format</a> (a “bag”). This includes a manifest with checksums that describes all the files.</p><p>The storage service unpacks the bag, and verifies the checksums. If they are correct, it makes two copies of the entire bag: one in S3, one in S3 Glacier. Then it verifies the two copies, to check the files weren’t corrupted in transit. Assuming all is well, it reports the bag as successfully stored.</p><p>If anything goes wrong, it reports the error to the user, and explains why the bag couldn’t be stored. For example: <em>“The checksum of cat.jpg did not match the checksum in the manifest”</em>.</p><p>You can read our initial design document <a href="https://github.com/wellcomecollection/docs/tree/master/rfcs/002-archival_storage">on GitHub</a>.</p><p>So that’s the idea… but how does that become a reality? We wrote code, but what does that look like?</p><h4>We reused existing knowledge to build a prototype</h4><p>We’d already built a service to supply the data for <a href="https://developers.wellcomecollection.org/catalogue">our Catalogue API</a>, so we reused a lot of the same ideas to build the initial storage service.</p><p>In particular, we built on standard AWS technologies, with the same architecture as the Catalogue API: a <em>pipeline</em>. The task of storing the bag is broken down into small steps, and each of these steps is a separate app. Those steps run in a line, and a bag flows from one step to the next:</p><figure><img alt="Illustration of a pipeline: four blue boxes, with arrows between them from left to right. [] ~&gt; [] ~&gt; [] ~&gt; []" src="https://cdn-images-1.medium.com/max/1024/1*J5jRp-6PDsgIIE91rk7YQw.png" /></figure><p>AWS gives us a reliable base to build on. Although it feels like we have a lot of files (~70M when we started the project), there are people who use AWS for orders of magnitude more data, and it copes fine. It’s enormously popular, so we know it’s reliable and it can scale to meet our needs.</p><p>Because we had a familiar architecture, we could reuse our existing tooling, and deploy and iterate really quickly. We could change the behaviour of each step independently, put steps in a different order, merge two steps together or break one apart, and so on. When we built the initial prototype, we were doing multiple deployments a day.</p><p>Fast iterations allowed us to improve our initial design, and get to a working prototype.</p><h4>We did soak testing to find scaling issues</h4><p>The prototype could store a handful of bags, but we need to store thousands of bags. And bags come in all shapes and sizes — some bags have lots of little files, or a handful of big files, or some mixture of the two.</p><p>How do we get to a point where the storage service can scale up reliably, and handle a variety of different bags?</p><p>We built an application to package the existing archive into bags, suitable to store in the storage service. Then we did regular, overnight <a href="https://en.wikipedia.org/wiki/Soak_testing"><em>soak tests</em></a><em>.</em> We’d send a sample of bags to be stored, and look at the errors that came out.</p><p>We might send 1% of the bags to be stored overnight, and in the morning there were 100 errors. We’d find the bug, fix it, deploy a new version.</p><p>The following night, we send another 1% of the bags to be stored, and in the morning there were only 50 errors. That’s an improvement! We’d find the bug, fix it, deploy a new version.</p><p>And so on. Repeating this process, we whittled down the bugs, until we could reliably send 10% of the bags in a single night and not see any errors. That gave us confidence that we could migrate 100% of the existing bags.</p><h4>We ratcheted up reliability with automated tests</h4><p>As we do these overnight runs, we’re finding and fixing plenty of bugs — but how do we know we’ve not introduced new bugs in the process? With <em>automated tests.</em></p><p>Imagine an expected behaviour of the storage service, say: <em>“if the bag is missing a file, then the bag should be rejected”.</em></p><p>Because computers are deterministic (mostly), we can write an automated test that checks this behaviour, and tells us if the code is broken. <em>“Send a bag with a missing file. Is the bag rejected?” </em>When the computer runs the test, if it doesn’t see the expected behaviour, the test fails, highlighting the error.</p><p>Every time we found a new bug, we wrote a new test: <em>“this bug should not occur”. </em>When the test passes, we know the bug is fixed. As long as the test keeps passing, we know that particular bug hasn’t been reintroduced.</p><p>And then we run all our tests every time we change code. Every proposed change to our repository is tested automatically by <a href="https://travis-ci.org/">Travis CI</a>, which gives a green tick (all the tests passed) or a red cross (one of the tests failed). If we get a red cross, we know we have more work to do.</p><p>The tests give us a safety net against mistakes, and every passing test gives us more confidence that the code is behaving correctly. As we write more tests, we can ratchet up our confidence in the service.</p><p>Is the current code bug-free? Almost certainly not — but when we find bugs, we can fix them and deploy new versions quickly.</p><h4>Migrating the digitised archive</h4><p>Once we’ve done our reliability testing, we needed to migrate all our content out of the old storage. We started by migrating the digitised archive, which is the majority of our files. How did that work?</p><ol><li>We turned off writes of new files into the old storage —so we only have to migrate a static collection, not something that’s changing under our feet. We had to coordinate with the digitisation team, to minimise the disruption to their workflow.</li><li>We created a bag for every item in the old collection — 260k items, so there were 260k bags.</li><li>We stored every single one of those bags in the storage service, with its internal checks and verifications that bags were correctly stored.</li><li>Then we ran a whole sequence of extra checks, comparing content in the old and the new storage. Had we created the correct bags? Had we sorted the files correctly? Had we missed any images? And so on.</li><li>Once we were happy everything had migrated successfully, we updated the Library website to read images from the new storage. If you’ve looked at any of our digitised content since last October, it was served from the new storage service!</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*c0Ijhw8f5uuZDpGAFeJxwg.png" /></figure><p>Overall the migration was very successful, and nobody noticed the switchover when it happened. It validated a lot of our reliability testing: we managed to store a decade’s worth of digitisation output in a fortnight.</p><p>Shortly afterwards, we reenabled writes, so our digitisation team could start saving new digitisation projects — but now they were being written into our new storage service, not the old storage.</p><h3>State of the storage service</h3><p>At the time of writing, we have all the migrated digitised content, and we’ve been using the storage service to store newly digitised files since October. We also have most of the uncatalogued born-digital material (although that’s a tiny fraction of the archive).</p><p>Here are some headline numbers:</p><figure><img alt="Three statistics: a number in blue text, description in black. L-R: 79M files, 56TB of data, $25k estimated annual cost." src="https://cdn-images-1.medium.com/max/1024/1*hewoi-yvCIS392_nBnJQvQ.png" /></figure><p>The estimated annual cost includes both the S3 storage, and the compute resource required to run the service. This is substantially cheaper than the alternatives we considered.</p><p>Part of the saving is because the storage service is only running when there are bags to store — it scales up to process the new bags, then scales down again afterwards. This makes it very efficient, and means we’re not paying for compute resource that we’re not using.</p><p>This doesn’t include the cost of developer time to support the service — but at the moment, it’s reliable enough that support is a small cost. Since we finished the digitised content migration in October, we haven’t had any bugs or outages, and we’ve barely had to do any work on it.</p><h3>What’s next?</h3><h4>Bring in our born-digital content</h4><p>We’ve already got our digitised content in the storage service, and now we’re migrating our born-digital content to live in the same place.</p><p>We’re setting up <a href="https://www.archivematica.org/en/">Archivematica</a> as our born-digital workflow manager, and we’ve made changes to Archivematica so it can write packages directly into our storage service.</p><h4>Better support for deleting files</h4><p>This might seem like an odd thing to want — we’re building a service to preserve files, so why do we want to delete things?</p><p>The answer: personal data.</p><p>After somebody has donated born-digital material to our collections, we do a process of sensitivity review. If we discover a collection contains large amounts of personal data, we might choose to remove those files from the archive.</p><p>The current process for deleting files is very manual, and we’d like to have better automation and auditing of deletions.</p><figure><img alt="Pencil drawing of two wind mills." src="https://cdn-images-1.medium.com/max/1024/1*xjhb7KKZYk_rTFwz8LV_xA.jpeg" /><figcaption>Two windmills in the Netherlands, maybe near the site of a future data centre? Pencil drawing, 1862. Credit: <a href="https://wellcomecollection.org/works/bwamtvdu">Wellcome Collection</a>. <a href="https://creativecommons.org/licenses/by/4.0/">CC BY</a></figcaption></figure><h4>Replication into Microsoft Azure in Amsterdam</h4><p>The current storage service has two copies of every file: one in S3, one in S3 Glacier, both in Amazon’s eu-west-1 region.</p><p>This isn’t ideal — it’s a single geographic location and a single cloud provider. If Amazon closes our account or there’s an accident at the data centre, we’d lose the entire archive.</p><p>For extra redundancy, we’d like to have a third copy of our data. We’re planning to add another replica in Microsoft’s Azure data centre in Amsterdam.</p><p>This will become part of the storage process — every time we store a new bag, we’ll make a copy in Azure before reporting the bag as successfully stored.</p><h4>Better visibility of statistics about the files we’re storing</h4><p>We want to be able to aggregate information across our collections. The archives contain millions of files, and a single person could never read all of them — but a machine can. You might ask questions like:</p><ul><li>How many images did we digitise last month?</li><li>What file formats are we holding? Are any of those formats about to go out-of-support?</li><li>How big are those files?</li></ul><p>We’re just beginning to provide this sort of data internally, and we’re excited to see how people use it!</p><h4>Help other people learn from the storage service</h4><p>All our code is open source and in a <a href="https://github.com/wellcometrust/storage-service">public repo</a>, and we hope other people can learn from what we’ve done.</p><p>I’ve been writing blog posts about some standalone parts of the code that might be usable in other contexts (<a href="https://alexwlchan.net/2019/09/streaming-large-s3-objects/">example</a>, <a href="https://alexwlchan.net/2019/09/unpacking-compressed-archives-in-scala/">example</a>, <a href="https://alexwlchan.net/2020/01/deletion-canary/">example</a>), and I expect to keep doing that.</p><p>We’re also trying to be better about documentation, so the repo will hopefully become easier to browse and understand soon.</p><p>Our new storage service gives us a reliable, robust platform for the next decade of digital archives at Wellcome. Lots of people worked really hard to get it in place, and we’re excited to see what we can build on top of it.</p><p>If you’d like to learn more:</p><ul><li>The code is on GitHub at <a href="https://github.com/wellcomecollection/storage-service">wellcomecollection/storage-service</a></li><li>The original design document is <a href="https://github.com/wellcomecollection/docs/tree/master/rfcs/002-archival_storage">available as an RFC</a></li></ul><p><em>Thanks to Alexandra Eveleigh, Robert Kenny, Jenn Phillips-Bacher, Tom Scott and Jonathan Tweed for their help writing this post.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f68ff21927e" width="1" height="1" alt=""><hr><p><a href="https://stacks.wellcomecollection.org/building-wellcome-collections-new-archival-storage-service-3f68ff21927e">Building Wellcome Collection’s new archival storage service</a> was originally published in <a href="https://stacks.wellcomecollection.org/">Stacks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Digital Preservation at Wellcome]]></title>
            <link>https://stacks.wellcomecollection.org/digital-preservation-at-wellcome-3f86b423047?source=rss-e34c74a2c5d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f86b423047</guid>
            <category><![CDATA[digital-preservation]]></category>
            <category><![CDATA[digitization]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[museums]]></category>
            <category><![CDATA[archive]]></category>
            <dc:creator><![CDATA[Alex Chan]]></dc:creator>
            <pubDate>Tue, 22 Oct 2019 10:02:48 GMT</pubDate>
            <atom:updated>2019-10-22T16:01:51.760Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p><em>This is the text version of a talk I gave at </em><a href="https://www.eventbrite.co.uk/e/glam-digital-champions-digital-lunch-october-tickets-73928130027"><em>a GLAM Digital Champions event</em></a><em> on 18th October 2019.</em></p><p><em>GLAM Digital Champions is a Cambridge-based community of practitioners for sharing ideas about the use of digital technologies in Gardens, Galleries, Libraries, Archives and Museums. It was set up by </em><a href="https://twitter.com/georgeopteryx"><em>George Doji</em></a><em> and </em><a href="https://twitter.com/marycktech"><em>Mary Chester-Kadwell</em></a><em>. I met Mary at PyCon UK this year, and she invited me to come and give a brief overview of how we’re doing digital preservation at Wellcome.</em></p><p><em>You can also </em><a href="https://prismic-io.s3.amazonaws.com/wellcomecollection%2Ff0586b2e-5463-4745-a43b-0960baeb9cfc_2019-10-18-glam-cam-digipres-slides.pdf"><em>download my slides</em></a><em> as a PDF.</em></p><figure><img alt="A room with circular, raked seating. Two men are talking, one pointing to a skeleton hanging from the skylight." src="https://cdn-images-1.medium.com/max/1024/1*fyMvoRF_tUlx-YSAkirZwA.jpeg" /><figcaption>The Anatomical Theatre in Cambridge. Published for R. Ackermann’s <em>History of Cambridge</em>. Credit: <a href="https://wellcomecollection.org/works/h76dp2d4">Wellcome Collection</a>. CC BY.</figcaption></figure><p>Hello everyone, and thank you having me. It’s a pleasure to be here in Cambridge.</p><p>My name is Alex. I’m a senior software developer at Wellcome Collection in London, and today I’m going to give you a brief overview of how we do digital preservation at Wellcome Collection.</p><p>For those of you who don’t know us, Wellcome Collection is <a href="https://wellcomecollection.org/pages/Wuw2MSIAACtd3Stq">a free museum and library that aims to challenge how we all think and feel about health</a>.</p><p>What does that actually mean?</p><p>Our building is a library, archive and museum all rolled into one. (No gardens yet, but we do have a couple of house plants!)</p><p>Wellcome Collection is a big place. We have a reference library and archive for researchers; we have a series of permanent and rotating exhibitions; we have event spaces and regular events; we write stories and we publish books. It covers a wide range of material around science, medicine, health and art. Alongside our physical archive, we have a large digital archive, and that’s what I’m going to talk about today.</p><p>We can imagine the process of digital preservation in three stages: production, storage, and retrieval. We choose what we’re going to save, we save it, we get it back later.</p><figure><img alt="A three step diagram. Production to storage, storage to retrieval." src="https://cdn-images-1.medium.com/max/1024/1*vR5fuMVndhE8A8ED8OqR1A.jpeg" /><figcaption>Icon credit: Legal archivist (production), by <a href="https://thenounproject.com/term/legal-archivist/1823613/">Miroslav Kurdov</a>. S3 bucket (storage) from <a href="https://commons.wikimedia.org/wiki/File:AWS_Simple_Icons_Storage_Amazon_S3.svg">AWS Simple Icons</a>. Legal counsel (retrieval), by <a href="https://thenounproject.com/term/legal-counsel/1824436">Miroslav Kurdov</a>.</figcaption></figure><p>Let’s discuss those steps in turn.</p><h3>Production</h3><p>The production process varies at Wellcome, depending on whether we are considering <a href="https://en.wikipedia.org/wiki/Digitization"><em>digitised</em></a> or <a href="https://en.wikipedia.org/wiki/Born-digital"><em>born-digital</em></a> files. Digitising means creating a digital representation of a physical object: for example, scanning a page or photographing a book. A born-digital file is one that started life as a digital file: maybe a Word document or a web page.</p><p>Let’s consider each in turn.</p><h4>Digitisation</h4><p>We have a lot of experience at Wellcome with digitisation: we’ve been digitising the collection for over a decade, and we have 40 million images.</p><p>How do we choose what to digitise? We have <a href="https://wellcomelibrary.org/what-we-do/digitisation/digitisation-schedules/">a long-term digitisation schedule</a>, for parts of the collection we want to digitise — often planned years in advance. We also have capacity for ad-hoc digitisation. If a researcher in New Zealand wants to see something from our collections, they can ask for that to be digitised specially, and we can try to accommodate.</p><p>So we know what we want to digitise, and we’ve picked it off the shelf — how does the digitisation happen? There are a couple of streams:</p><ul><li>We have a contract with <a href="https://archive.org/scanning">the Internet Archive</a>, who scan our bound, printed books. They have specialist book scanners that mean they can scan very quickly.</li><li>We send audiovisual material (VHS tapes, audio cassettes, etc.) to <a href="https://r3storestudios.com/">R3Store</a>.</li><li><a href="https://www.townswebarchiving.com/">TownsWeb</a> work on-site at Euston Road and help to digitise our paper archives.</li><li>We’re lucky to have a team of in-house photographers, who handle anything that needs extra care — maybe it’s fragile, bulky, or even radioactive. They work closely with the conservation team.</li></ul><p>Now we have a pile of images, and we need to add them to the catalogue. We use a workflow manager called <a href="https://www.intranda.com/en/digiverso/goobi/goobi-overview/">Goobi</a>, made by Intranda. It collates metadata and OCR, adds checksums to the files, and spits out a bundle of images, <a href="https://en.wikipedia.org/wiki/Metadata_Encoding_and_Transmission_Standard">METS</a> (metadata) and <a href="https://en.wikipedia.org/wiki/ALTO_(XML)">ALTO</a> (OCR data).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vls47QYBTA-MLhiaQ0444A.png" /><figcaption>A screenshot of Goobi, from <a href="https://www.intranda.com/en/digiverso/goobi/goobi-overview/">Intranda’s website</a>.</figcaption></figure><h4>Born-digital</h4><p>Born-digital archiving is something newer for us at Wellcome: it was the new shiny a few years ago, and we brought in lots of material. Now we’re starting to think more carefully about how we want to do born-digital archiving, how we’re going to catalogue it, and so on.</p><p>Suppose somebody offers us some files — we start by assessing them. Are these files a good fit for our collection? If they are, we’ll transfer them to Wellcome, and go through them in more detail. This is a more thorough analysis, where we’re looking for files that might need extra work before we can make it available. For example, PDFs of medical research are easier to present than something that’s password-protected.</p><p>To prepare the files for ingest, we are about to start using <a href="https://www.archivematica.org/en/">Archivematica</a>, an open-source digital preservation system made by Artefactual. It does a lot of automation for us: virus scanning, generating metadata and checksums, deleting <a href="https://en.wikipedia.org/wiki/.DS_Store">.DS_Store</a> and <a href="https://en.wikipedia.org/wiki/Windows_thumbnail_cache#Thumbs.db">thumbs.db</a> files that we don’t care about, and it spits out a bundle of files and metadata.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lya8QRpYJe2b9RMHGIKCiQ.png" /><figcaption>A screenshot of our Archivematica instance.</figcaption></figure><p>That gives you a brief overview of our production process, both digitised and born-digital.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ufbrVq09zlHEUDhavUm-Xw.jpeg" /></figure><p>At the end of this process, we have a clutch of files and metadata, but nowhere to put them. Where do keep these precious things? Let’s talk about storage.</p><h3>Storage</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EoyW2yIN3mUPlRBe-sl_WA.png" /></figure><p>Historically, we’ve used a storage system called <a href="https://preservica.com/">Preservica</a>, which is a fairly popular service used for digital preservation. (Although judging by hands in the room, it has yet to reach Cambridge!)</p><p>We’re in the process of migrating our storage away from Preservica. We wanted a storage service with the following attributes:</p><ul><li>Based on a common, open format for ingesting both digitised and born-digital assets</li><li>A preference for open-source software</li><li>That would allow us to batch process large volumes of data quickly. For example, if we wanted to re-run the OCR process for our digitised images.</li><li>Human-readable storage layout. We want to make it as easy as possible for future developers to understand the storage, even if the current service is no longer in use.</li><li>Running in the cloud, with content replicated to different locations and providers.</li><li>Conforming to the <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY (Don’t repeat yourself)</a> principles</li></ul><p>And so we’re in the process of migrating our content from Preservica up to our new storage service. (As in, half an hour before the talk, I was in a café running migration scripts!)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UuDm5nnqC5r-ssTLan1j7A.jpeg" /></figure><p>In our new storage service, you upload files in <a href="https://en.wikipedia.org/wiki/BagIt">a BagIt package</a>. This is a standard packaging format, used to pass around hierarchical filesystems. It’s often used in digital libraries, and both Goobi and Archivematica can produce BagIt packages.</p><p>The storage service unpacks the BagIt “bag”, counts out the files, verifies the checksums, and generally checks everything is in order. Assuming all is well, it uploads a copy of the bag to Amazon S3, and a second copy to S3 Glacier.</p><p>Later next year, we’ll be adding a replica to Azure Blob Storage in Amsterdam (both our S3 copies are in Dublin). This gives us an extra layer of redundancy and protection, in case AWS close our account or Dublin falls into the sea.</p><p>We know we’re lucky to have in-house software developers, so we want to share this work as much as possible. All the code for the storage service is <a href="https://github.com/wellcometrust/storage-service">open-source and MIT licensed</a>, as is the <a href="https://github.com/wellcometrust/platform/tree/master/docs/rfcs/002-archival_storage">original design document</a>.</p><p>So we upload packages to the storage service, which keeps them safe in cloud storage for preservation evermore. Now suppose somebody comes to our website, and they want to see something we’ve preserved. How do they get it out? Let’s finish by discussing retrieval.</p><p><em>[Somebody asked about versioning in the Q&amp;A — for example, what if we’ve digitised a book, and we need to replace one of the images?</em></p><p><em>The BagIt spec supports partial updates with “fetch files”. You build a package with a replacement image, and a fetch file that refers to files in another location — in our case, the location of previously stored bag.</em></p><p><em>The storage service tracks the versions of a given bag, keeps every version forever, and lets you see how a bag looked at a particular point in time.]</em></p><h3>Retrieval</h3><p>We have a number of services that sit in front of the storage service, and serve content to our website. Right now we only serve digitised content, but we want to think about how to do born-digital in the future.</p><p><a href="https://digirati.com/work/galleries-libraries-archives-museums/products/digital-library-cloud-services/"><em>DLCS (Digital Library Cloud Services)</em></a><em> </em>is a service that provides <a href="https://en.wikipedia.org/wiki/International_Image_Interoperability_Framework">IIIF APIs</a> for our digitised content. IIIF is a set of standards for presenting large images, commonly used in museums and libraries. DLCS presents three types of IIIF API for us:</p><ul><li>The <em>IIIF Presentation API</em> tells you what images are available in a particular work. If a book has 100 pages, and there are 100 digitised images, the Presentation API tells you how to find them.</li><li>The <em>IIIF Image API</em> returns the images themselves. It can scale all the way from a tiny thumbnail (if you’re just skimming) to a deep zoomed version (if you’re studying in detail). This includes converting the image to different formats. Our original images are all JPEG2000, but we usually serve them as regular JPEG.</li><li>The <em>IIIF Auth API</em> controls access to images. Most of our images are completely open access, but there are a handful where we need some access controls — for example if it’s an archive about somebody who’s still alive or recently deceased.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*Yg-L-t_LAox7F5iCv_Lzag.png" /><figcaption>An illustration of two Lorises. “The Slender Loris, in waking and sleeping posture.” Taken from <a href="https://commons.wikimedia.org/wiki/File:SlenderLorisLyd2.png">Royal Natural History volume 1, page 230</a>. Public domain.</figcaption></figure><p><a href="https://github.com/loris-imageserver/loris"><em>Loris</em></a><em> </em>is an open-source IIIF Image API server that we use to serve the other images on our website (a handful of catalogue images, and editorial images for events and exhibitions).</p><p>Presenting all the images on the site through IIIF gives them a consistent interface — the same code can be used to retrieve images everywhere.</p><p>(I previously wrote about <a href="https://stacks.wellcomecollection.org/using-loris-for-iiif-at-wellcome-6ed1fefaf801">our use of Loris</a> in 2017.)</p><p>So that’s how we get the images —but what about the metadata that goes with them?</p><figure><img alt="A search box with the text “unified catalogue search”" src="https://cdn-images-1.medium.com/max/1024/1*ur1I7fXRMlk2kzIsxHZSXQ.png" /></figure><p>A lot of our metadata is split across different databases: Sierra for our library catalogue, Calm for our archives, Miro for our image collections, and so on. The same object is split across multiple places, and it’s hard for users to find it. It’s not clear which search box to use, and you only get a partial record.</p><p>We’ve been building a unified catalogue search that combines records from multiple databases, transforms them into a unified model, and presents all the data in one place. There’s also an open API that lets you get the search results as JSON, so other people can build their own tools on top of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qzr8XlrC5gmo3LqY4eNGhA.png" /><figcaption>Screenshot from <a href="https://wellcomecollection.org/works/ptnfbubj">https://wellcomecollection.org/works/ptnfbubj</a></figcaption></figure><p>What ties it all together is the new Wellcome Collection website, where people can browse the catalogue in a nice graphical viewer.</p><p>We’ve completely redesigned it, with new works pages for presenting this unified catalogue. It includes a IIIF viewer for doing deep zoom of images and browsing the pages of a book (pictured above). The new website is also much more accessible: it uses progressive enhancement and the OCR from our digitisation as alt text in the images.</p><p>Under the hood, it’s using the Catalogue API to get metadata, and DLCS and Loris to serve the images. We do a lot of user research on the website to get a sense of how well search is performing, how easily people are finding what they need, to track site performance, and so on.</p><p>So now we’ve gone from start to finish: we’ve chosen something we want to store, we’ve saved it in the storage service, and somebody has found it through our website on the other side. I hope this has given you a flavour of how we do digital preservation at Wellcome.</p><h3>Read more</h3><p>If you want to discuss this in more detail, email me: <a href="/service/mailto:a.chan@wellcome.ac.uk">a.chan@wellcome.ac.uk</a>. I’ll try to answer your question, or pass you to somebody else who can.</p><p>Browse the catalogue: <a href="https://wellcomecollection.org/works">wellcomecollection.org/works</a></p><p>Get our code: <a href="https://github.com/wellcometrust/platform">github.com/wellcometrust/platform</a></p><p>Browse our developer docs, learn how to use our APIs: <a href="https://developers.wellcomecollection.org/">developers.wellcomecollection.org/</a></p><p><em>Thanks to Christy Henshaw, Jonathan Tweed and Tom Scott for their help reviewing drafts of this talk.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f86b423047" width="1" height="1" alt=""><hr><p><a href="https://stacks.wellcomecollection.org/digital-preservation-at-wellcome-3f86b423047">Digital Preservation at Wellcome</a> was originally published in <a href="https://stacks.wellcomecollection.org/">Stacks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Peering through MRI scans of fruit and veg, part 1]]></title>
            <link>https://stacks.wellcomecollection.org/peering-through-mri-scans-of-fruit-and-veg-part-1-a2e8b07bde6f?source=rss-e34c74a2c5d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2e8b07bde6f</guid>
            <category><![CDATA[mri-scan]]></category>
            <dc:creator><![CDATA[Alex Chan]]></dc:creator>
            <pubDate>Wed, 31 Oct 2018 09:10:26 GMT</pubDate>
            <atom:updated>2021-05-15T08:54:58.691Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Peering through MRI scans of fruit and veg</h3><p>Having a <a href="https://wellcomecollection.org/works">large image collection to play with</a> means we’ve never short of a good illustration. Recently, somebody used an image of an MRI scan of a pumpkin as the cover picture on an internal blog post. Pretty appropriate in the run-up to Halloween:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5fSo5z8mDgCSPy6dTZWySg.jpeg" /><figcaption>An MRI scan along the axis of a pumpkin. By Alexandr Khrapichev, University of Oxford. Source: <a href="https://wellcomecollection.org/works/rb4sm6fd">Wellcome Collection</a>, CC BY.</figcaption></figure><p>It’s one of a <a href="https://wellcomecollection.org/works?query=creators%3A%22Alexandr%20Khrapichev%2C%20University%20of%20Oxford%22">series of MRI scans</a> of fruit and vegetables. All the images were created by Alexandr Khrapichev, from the University of Oxford.</p><p>An MRI scan is a way to look inside the human body when other types of scanner can’t be used. It’s painless, non-invasive, and can give very high-resolution images. Rather than using x-ray or ultrasound, it uses powerful magnets to affect the movement of water molecules. (Remember that humans are 70% water!) Those movements can be used to construct an image.</p><p>Often — as seen here — a single MRI scan takes multiple “slices”. Each slice is a single cross-section of the body, and taking different slices gives you a detailed impression of the body’s interior.</p><p>In images like this one, Khrapichev has taken slices of a fruit or vegetable, used colours to match the original, and then stitched them together into a single high-resolution image. It’s a bit of fun, and it nicely illustrates how an MRI scan works.</p><p>When I saw these images, I wanted to break them back into individual slices, and combine them into an animated GIF. For me at least, that works a lot better than seeing them laid out on a static page. Since these images are all licensed as CC BY, I’m okay to do that, as long as I link back to the originals!</p><p>I’ve been sharing a few examples <a href="https://twitter.com/alexwlchan">on my Twitter account</a>, but I wanted to give them a more permanent home. The full resolution images are gorgeous, and the compression on Twitter doesn’t do it justice.</p><p>In this post, I’ll show off some of my favourite images. In a sequel, I’ll explain the code I used to create them.</p><p>Let’s start with something quite familiar: an apple. Turning it into a GIF shows the shape of the apple, and we can see the gaps in the core:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0A1CEwcu9jXLh7l4WReFZA.gif" /><figcaption>Based on an MRI scan of a sagittal view of an apple. Original images by Alexandr Khrapichev, University of Oxford. Source: <a href="https://wellcomecollection.org/works/mwn9qf6m">Wellcome Collection</a>, CC BY.</figcaption></figure><p>Here’s another pair of images which are really familiar: a mandarin and a lemon. Within the MRI, you can see the segments of the two citrus fruits — and the occasional flash of a seed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J6_xF89Y6UqsuY0Ft6hc2g.gif" /><figcaption>Based on an MRI scan of an axial view of an lemon. Original images by Alexandr Khrapichev, University of Oxford. Source: <a href="https://wellcomecollection.org/works/t2h4c4n3">Wellcome Collection</a>, CC BY. It’s hard to be sure, but I think this scan must start partway through the lemon — we don’t see it shrink at the ends.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y6ZEP5NxeNJ-8RA7NbAi-Q.gif" /><figcaption>Based on an MRI scan of an axial view of an orange. Original images by Alexandr Khrapichev, University of Oxford. Source: <a href="https://wellcomecollection.org/works/sxm89b3x">Wellcome Collection</a>, CC BY.</figcaption></figure><p>I love the vibrancy of the bright orange against the black background. The side view is equally impressive:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sw_sCusnQhbAz5zBey_GVQ.gif" /><figcaption>Based on an MRI scan of a sagittal view of an orange. Original images by Alexandr Khrapichev, University of Oxford. Source: <a href="https://wellcomecollection.org/works/semnhwc6">Wellcome Collection</a>, CC BY.</figcaption></figure><p>I’m also rather taken with the red in this tomato. I can see the aspects of a tomato when I look at it, but I don’t think it’s quite as recognisable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NGUMEkAvlyqmQC43SpgCPw.gif" /><figcaption>Based on an MRI scan of an axial view of a tomato. Original images by Alexandr Khrapichev, University of Oxford. Source: <a href="https://wellcomecollection.org/works/nmppywpm">Wellcome Collection</a>, CC BY.</figcaption></figure><p>Turning towards the more unusual, this is a kiwifruit. Not only is it a pleasing shade of green, it also shows off the structure nicely. The core and the seeds really stand out in this image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nMJOS6lMoxjFlVWGgW796g.gif" /><figcaption>Based on an MRI scan of an axial view of a kiwfruit. Original images by Alexandr Khrapichev, University of Oxford. Source: <a href="https://wellcomecollection.org/works/aqzd3qh7">Wellcome Collection</a>, CC BY.</figcaption></figure><p>Going for something even odder, this scan of a passion fruit looks closer to frog spawn than fruit — in fact, it’s the numerous seeds. Once you know what it is, it makes a lot more sense!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-lRkN1t4HKnm5tt7E6q6Iw.gif" /><figcaption>Based on an MRI scan of an axial view of a passion fruit. Original images by Alexandr Khrapichev, University of Oxford. Source: <a href="https://wellcomecollection.org/works/xkn4pw2u">Wellcome Collection</a>, CC BY.</figcaption></figure><p>Here’s another one which is quite unusual, and which I find almost mesmerising. It looks like something from the world of microbiology — a cluster of tiny cells — but it’s much larger. Can you guess what it is?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TRERlZijFg-iA9Xu3kCouA.gif" /><figcaption>Based on an MRI scan of an axial view of… well, something. Original images by Alexandr Khrapichev, University of Oxford. Source: <a href="https://wellcomecollection.org/works/qbv99v5k">Wellcome Collection</a>, CC BY.</figcaption></figure><p>Any ideas? If it helps, here’s another view of the same object, this time from a different angle:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aJuRWvqdag11FD-BU3ZLyw.gif" /><figcaption>A sagittal view of the same object. I can’t help but see animal faces peering at me from the dark, but maybe that’s just me… Original images by Alexandr Khrapichev, University of Oxford. Source: <a href="https://wellcomecollection.org/works/vwp2yvdd">Wellcome Collection</a>, CC BY.</figcaption></figure><p>Did you guess correctly?</p><p>This is garlic — each segment is an individual clove, which grows as we move from one end towards the centre, then tapers off again at the other end.</p><p>There are some even weirder ones. This axial view of a cabbage puts me in mind of the opening credits of <em>Doctor Who</em>. It’s almost hypnotic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fmpbt4SBWebr-S3L19KLxQ.gif" /><figcaption>Based on an MRI scan of an axial view of a cabbage. Original images by Alexandr Khrapichev, University of Oxford. Source: <a href="https://wellcomecollection.org/works/rq48tke5">Wellcome Collection</a>, CC BY.</figcaption></figure><p>And the other view of the cabbage isn’t any less strange — like a sort of magical forest, the trees growing alongside the path to greet you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Ygqw2ZXPzsaY45dDBHQPg.gif" /><figcaption>Based on an MRI scan of a sagittal view of a cabbage. Original images by Alexandr Khrapichev, University of Oxford. Source: <a href="https://wellcomecollection.org/works/kgz34m4e">Wellcome Collection</a>, CC BY.</figcaption></figure><p>Somehow, these images make cabbage seem much more interesting than when I had it for school dinners.</p><p>But what most surely be my favourite bizarre image is the artichoke. The collage image is a bit odd, but stitching them together looks like a portal opening in space. (Has anybody ever used images from an MRI in a<br>science-fiction show?)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*re6vsssoSzSnuvVMXqoOBw.gif" /><figcaption>Based on an MRI scan of a sagittal view of an artichoke. Original images by Alexandr Khrapichev, University of Oxford. Source: <a href="https://wellcomecollection.org/works/b9g485fs">Wellcome Collection</a>, CC BY.</figcaption></figure><p>And finally, to round out this post, here a GIF of the pumpkin I opened the post with:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*khJavcBL8IB_j_JkFOpNqg.gif" /><figcaption>Based on an MRI scan of an axial view of a pumpkin. Original images by Alexandr Khrapichev, University of Oxford. Source: <a href="https://wellcomecollection.org/works/rb4sm6fd">Wellcome Collection</a>, CC BY.</figcaption></figure><p>Happy Halloween!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2e8b07bde6f" width="1" height="1" alt=""><hr><p><a href="https://stacks.wellcomecollection.org/peering-through-mri-scans-of-fruit-and-veg-part-1-a2e8b07bde6f">Peering through MRI scans of fruit and veg, part 1</a> was originally published in <a href="https://stacks.wellcomecollection.org/">Stacks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a data store from S3 and DynamoDB]]></title>
            <link>https://stacks.wellcomecollection.org/creating-a-data-store-from-s3-and-dynamodb-8bb9ecce8fc1?source=rss-e34c74a2c5d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bb9ecce8fc1</guid>
            <category><![CDATA[digital]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[storage]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Alex Chan]]></dc:creator>
            <pubDate>Wed, 16 May 2018 12:12:50 GMT</pubDate>
            <atom:updated>2018-05-16T12:12:50.882Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, I’m going to explain one of the storage layers in our catalogue pipeline.</p><p>Our Catalogue API provides information about works in Wellcome Collection. This information is combined from multiple sources — our library catalogue, archive records, image collections, and so on. Data from each of these sources is ingested in the <a href="https://stacks.wellcomecollection.org/whats-in-the-box-addfe6ae16d4">catalogue pipeline</a>, transformed into a shared domain model, and presented in the API.</p><p>The first step of the ingest process is an <em>adapter</em> — a service that copies all the records from a source system into our own database. We have several source systems, and one adapter for each.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uK2VthyPxJYi0__9w-LurA.png" /></figure><p>Records in the source systems are typically structured objects — usually XML or JSON.</p><p>Copying the records into our own database gives us a common interface to the source data, and lets us query or reprocess the entire data set without causing undue load on the source systems.</p><p>When we wrote the original catalogue pipeline, we used <a href="https://en.wikipedia.org/wiki/Amazon_DynamoDB">DynamoDB</a> as our common data store. DynamoDB is a hosted NoSQL database provided by AWS, and it’s a good way to store structured objects. When we were ingesting data from Wellcome Images, this worked very well.</p><p>Then we started processing the library catalogue, and we realised that DynamoDB was no longer a good fit for our use case. In this post, I’ll explain the new system we had to build.</p><h3>The problem with DynamoDB</h3><p>Some of the records in our library catalogue are very large — for example, a box containing individually catalogued papers, or a journal with hundreds of issues. When we tried to copy the library records into DynamoDB, we started getting errors:</p><blockquote>com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: Item size has exceeded the maximum allowed size (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException)</blockquote><p>A single row in DynamoDB can’t be larger than <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html#limits-items">than 400 KB</a>, but that’s smaller than some of our library records. Anything bigger than that was being lost.</p><p>We considered compressing the strings we save to DynamoDB, but that’s only a short-term fix. Even with compression, eventually we’d find a source record which was too big to store. And soon we’ll be ingesting <a href="https://en.wikipedia.org/wiki/ALTO_(XML)">ALTO files</a>, which contain OCR’d copies of entire books. Those are much bigger than 400KB!</p><p>Alternatively, we could have split records across multiple tables — but that makes it much harder to ensure updates are applied consistently. And again, the prospect of much larger records in a future system meant this would only be a short-term fix.</p><p>So we had to look beyond just DynamoDB.</p><h3>S3 to the rescue?</h3><p>If you want to store arbitrary large objects in AWS, most people don’t think of DynamoDB — they think of S3. We already use S3 to store assets (large images, videos, audio files, and so on), so could we use it for metadata? Rather than saving a row in DynamoDB, we could serialise the row as JSON, and upload the JSON file.</p><p>If we were taking a one-time snapshot, this could work. But the library catalogue is being continually updated — new records are added, old ones are edited. Our adapters are constantly polling the catalogue to get these updates, and storing them in our database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SvctooTU_IjZ0W3PiezucQ.png" /><figcaption>If two versions of an object are written to S3 at the same time, there’s no guarantee which version will “win”.</figcaption></figure><p>When we store a record, we mustn’t overwrite a record with an older version. In DynamoDB, we can do a <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.ConditionalUpdate">conditional write</a> to ensure that we only ever store a newer version than what we already have — but S3 has no such mechanism.</p><p>If two processes try to write to S3 at once (with two different versions of the same record), either version could end up saved long-term.</p><p>So we can’t use S3 either.</p><h3>Why not both?</h3><p>DynamoDB and S3 both have useful properties. S3 can store records of any size, and DynamoDB gives us conditional writes to ensure we update records in the right order. We can get the best of both worlds.</p><p>In our new system, we store the body of the record in S3, and just keep a pointer to it in DynamoDB.</p><p>And indeed, that’s the approach <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-use-s3-too.html">recommended by the AWS docs</a>:</p><blockquote>If your application needs to store more data in an item than the DynamoDB size limit permits, you can try compressing one or more large attributes, or you can store them as an object in Amazon Simple Storage Service (Amazon S3) and store the Amazon S3 object identifier in your DynamoDB item.</blockquote><p>Here’s what the new architecture looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jrlt3P3HvACs8P4Suv8wiw.png" /></figure><p>A row in DynamoDB has three fields: an identifier, a version, and a pointer to an S3 object. The identifier is taken from the source system, the version is used to order updates, and the S3 pointer refers to a file in S3 containing the rest of the record.</p><p>The S3 object is typically a JSON file containing a serialisation of the source record.</p><p>When we store a record, we:</p><ol><li>Upload a file containing the record to a new S3 key (more on keys below)</li><li>Update the row in DynamoDB with a pointer to the new S3 object</li></ol><p>If the upload to S3 fails, or we discover there’s already a newer version in DynamoDB, we’re okay. The DynamoDB record stays the same, and because each new record is uploaded to a new S3 key, the existing S3 pointer is still correct.</p><p>And to retrieve a record, it’s the same process in reverse:</p><ol><li>Read the row from DynamoDB, and get a pointer to S3</li><li>Download the file from S3</li></ol><h3>Technical details</h3><h4>Versions in DynamoDB</h4><p>Our source systems don’t give us a versioning scheme — they only tell us when a record was last updated — so we have to provide our own.</p><p>When we want to update a record, we:</p><ol><li>Read the existing record. If there isn’t one, we write a new record with version 1.</li><li>Check if the existing record has a last updated date which is newer than the update we’re about to write. If the existing record is newer, we can discard the update immediately. If the updated record is newer, we write our updated record, and increment the version by 1.</li></ol><p>When we write to DynamoDB, we do a conditional write that says <em>“the current version is what we read in step 1”</em>. That way, we know nobody else has written something else in the meantime.</p><p>If the write fails, we retry from step 1. If we retry several times and it never stores successfully, we assume there’s something faulty about the record and send it to a dead-letter queue. This triggers an alarm, and we can investigate the fault.</p><h4>Choosing an S3 key</h4><p>We write S3 keys with the following pattern:</p><blockquote>s3://{bucket-name}/{shard}/{id}/{hash(content)}.json</blockquote><p>Storing all the copies of the same ID under a common prefix is for humans — it’s occasionally useful for us to inspect the contents of the bucket. We could look up the pointer in DynamoDB, but having an easy-to-navigate structure is more convenient, and at no real cost.</p><p>We use <a href="https://en.wikipedia.org/wiki/Shard_(database_architecture)">sharding</a> to spread keys across the bucket, which improves <a href="https://aws.amazon.com/blogs/aws/amazon-s3-performance-tips-tricks-seattle-hiring-event/">S3 performance</a>.</p><p>The final part of the key is a <a href="https://en.wikipedia.org/wiki/MurmurHash#MurmurHash3">MurmurHash3</a> of the file contents. This gives us deterministic names for our files — different files are written to different keys, so if an update is rejected in DynamoDB, the existing pointer is preserved. But if we upload the same filemultiple times, it always gets stored in the same key — which makes the bucket a bit neater, and reduces storage costs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bmXtIV4a1-tgjywPMCsZUA.png" /><figcaption>We have lots of <a href="https://en.wikipedia.org/wiki/VHS">VHS tapes</a> in our <a href="https://wellcomelibrary.org/collections/about-the-collections/moving-image-and-sound-collection/">Moving Image and Sound Collection</a> — along with plenty of other old formats. Reusing this acronym has been in no way confusing. Image by <a href="https://www.pexels.com/photo/cassette-electronics-equipment-film-157542/">Anthony from Pexels</a>, CC0.</figcaption></figure><h4>What’s in a name?</h4><p>This data store holds versioned copies of records. It’s a hybrid of DynamoDB and S3. Hence, we settled upon the name <em>Versioned Hybrid Store</em>, or <em>VHS</em> for short.</p><p>We say “an instance of the VHS” to refer to the combination of the DynamoDB table and the S3 bucket.</p><h3>Final thoughts</h3><p>We’ve been using the VHS for a number of months, and it’s been pretty seamless. We had a few teething issues when we were sorting out the initial schema, and migrating the existing DynamoDB databases — but after that, it’s worked very well.</p><p>Like everything we’ve written, the VHS code is available on GitHub and under an MIT license. It tends to move around a bit, so this may not stay current for long — but the current version is in <a href="https://github.com/wellcometrust/platform/blob/570ad391fe0b9cc56be1d7d4363e11c9ba5f2ce1/sbt_common/storage/src/main/scala/uk/ac/wellcome/storage/vhs/VersionedHybridStore.scala">VersionedHybridStore.scala</a>.</p><p><em>Thanks to Hannah Brown, James Gorrie, Robert Kenny, and Tom Scott for reviewing drafts of this post.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bb9ecce8fc1" width="1" height="1" alt=""><hr><p><a href="https://stacks.wellcomecollection.org/creating-a-data-store-from-s3-and-dynamodb-8bb9ecce8fc1">Creating a data store from S3 and DynamoDB</a> was originally published in <a href="https://stacks.wellcomecollection.org/">Stacks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>