<?xml version="1.0" encoding="UTF-8"?>
<feed
  xmlns="http://www.w3.org/2005/Atom"
  xmlns:thr="http://purl.org/syndication/thread/1.0"
  xml:lang="en"
   >
  <title type="text">Where am I?</title>
  <subtitle type="text">Performance, scalability, databases, and whatever comes up.</subtitle>

  <updated>2012-05-18T01:00:51Z</updated>
  <generator uri="http://blogofile.com/">Blogofile</generator>

  <link rel="alternate" type="text/html" href="http://blakeley.com/blogofile" />
  <id>http://blakeley.com/blogofile/feed/atom/</id>
  <link rel="self" type="application/atom+xml" href="http://blakeley.com/blogofile/feed/atom/" />
  <entry>
    <author>
      <name></name>
      <uri>http://blakeley.com/blogofile</uri>
    </author>
    <title type="html"><![CDATA[rsyslog and MarkLogic]]></title>
    <link rel="alternate" type="text/html" href="http://blakeley.com/blogofile/2012/05/17/rsyslog-and-marklogic" />
    <id>http://blakeley.com/blogofile/2012/05/17/rsyslog-and-marklogic</id>
    <updated>2012-05-17T18:00:01Z</updated>
    <published>2012-05-17T18:00:01Z</published>
    <category scheme="http://blakeley.com/blogofile" term="MarkLogic" />
    <category scheme="http://blakeley.com/blogofile" term="Linux" />
    <summary type="html"><![CDATA[rsyslog and MarkLogic]]></summary>
    <content type="html" xml:base="http://blakeley.com/blogofile/2012/05/17/rsyslog-and-marklogic"><![CDATA[<p>You probably know that MarkLogic Server logs important events
to the <code>ErrorLog.txt</code> file. By default it logs events at <code>INFO</code> or higher,
but many development and staging environments change the <code>file-log-level</code>
to <code>DEBUG</code>. These log levels are also available to the <code>xdmp:log</code> function,
and some of your XQuery code might use that for <code>printf</code>-style debugging.</p>
<p>You might even know that MarkLogic also sends important events
to the operating system. On linux this means <code>syslog</code>, and important events
are those at <code>NOTICE</code> and higher by default.</p>
<p>But are you monitoring these events?</p>
<p>How can you set up your MarkLogic deployment so that it will automatically
alert you to errors, warnings, or other important events?</p>
<p>Most linux deployments now use <code>rsyslog</code> as their system logging facility.
The <a href="http://www.rsyslog.com/doc/manual.html">full documentation</a> is available,
but this brief tutorial will show you how to set up email alerts for MarkLogic
using <code>rsyslog</code> version 4.2.6.</p>
<p>All configuration happens in <code>/etc/rsyslog.conf</code>.
Here is a sample of what we need for email alerts.
First, at the top of the file you should see several <code>ModLoad</code> declarations.
Check for <code>ommail</code> and add it if needed.</p>
<pre><code>$ModLoad ommail.so  # email support
</code></pre>
<p>Next, add a stanza for MarkLogic somewhere after the <code>ModLoad</code> declaration.</p>
<pre><code># MarkLogic
$template MarkLogicSubject,"Problem with MarkLogic on %hostname%"
$template MarkLogicBody,"rsyslog message from MarkLogic:\r\n[%timestamp%] %app-name% %pri-text%:%msg%"
$ActionMailSMTPServer 127.0.0.1
$ActionMailFrom your-address@your-domain
$ActionMailTo your-address@your-domain
$ActionMailSubject MarkLogicSubject
#$ActionExecOnlyOnceEveryInterval 3600
daemon.notice   :ommail:;MarkLogicBody
</code></pre>
<p>Be sure to replace both instances of <code>your-address@your-domain</code>
with an appropriate value. The ActionMailSMTPServer must be smart enough
to deliver email to that address. I used a default <code>sendmail</code> configuration
on the local host, but you might choose to connect to a different host.</p>
<p>Note that I have commented out the <code>ActionExecOnlyOnceEveryInterval</code> option.
The author of <code>rsyslog</code>, <a href="http://www.gerhards.net/rainer">Rainer Gerhards</a>,
recommends setting this value to a reasonably high number of seconds
so that your email inbox is not flooded with messages.
However, the <code>rsyslog</code> documentation states that excess messages
are discarded, and I did not want to loose any important messages.
What I would really like to do is buffer messages for N seconds at a time,
and merge them together in one email.
But while <code>rsyslog</code> has many features, and does offer buffering,
it does not seem to know how to combine consecutive messages
into a single email.</p>
<p>Getting back to what <code>rsyslog</code> <em>can</em> do,
you can customize the subject and body of the mail message.
With the configuration above, a restart of the server
might send you an email like this one:</p>
<pre><code>Subject: Problem with MarkLogic on myhostname.mydomain

rsyslog message from MarkLogic:
[May 17 23:58:36] MarkLogic daemon.notice&lt;29&gt;: Starting MarkLogic Server 5.0-3 i686 in /opt/MarkLogic with data in /var/opt/MarkLogic
</code></pre>
<p>When making any <code>rsyslog</code> changes, be sure to restart the service:</p>
<pre><code>sudo service rsyslog restart
</code></pre>
<p>At the same time, check your system log for any errors or typos.
This is usually <code>/var/log/messages</code> or <code>/var/log/syslog</code>.
The full documentation for <a href="http://www.rsyslog.com/doc/property_replacer.html">template substitution properties
</a> is online.
You can also read about a wealth of other options available in <code>rsyslog</code>.</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://blakeley.com/blogofile</uri>
    </author>
    <title type="html"><![CDATA[AlbumMixer v1.12]]></title>
    <link rel="alternate" type="text/html" href="http://blakeley.com/blogofile/2012/05/16/albummixer-v1.12" />
    <id>http://blakeley.com/blogofile/2012/05/16/albummixer-v1.12</id>
    <updated>2012-05-16T10:40:00Z</updated>
    <published>2012-05-16T10:40:00Z</published>
    <category scheme="http://blakeley.com/blogofile" term="iOS" />
    <summary type="html"><![CDATA[AlbumMixer v1.12]]></summary>
    <content type="html" xml:base="http://blakeley.com/blogofile/2012/05/16/albummixer-v1.12"><![CDATA[<p><a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=329552764">AlbumMixer v1.12</a>
fixes a minor bug where the player state would be wrong
when returning from background mode.</p>
<p>If you see any problems with this release,
please use <code>Settings &gt; Report a Problem</code> from within the app.
I will also read comments posted here.</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://blakeley.com/blogofile</uri>
    </author>
    <title type="html"><![CDATA[AlbumMixer v1.11]]></title>
    <link rel="alternate" type="text/html" href="http://blakeley.com/blogofile/2012/03/30/albummixer-v1.11" />
    <id>http://blakeley.com/blogofile/2012/03/30/albummixer-v1.11</id>
    <updated>2012-03-30T12:34:56Z</updated>
    <published>2012-03-30T12:34:56Z</published>
    <category scheme="http://blakeley.com/blogofile" term="iOS" />
    <summary type="html"><![CDATA[AlbumMixer v1.11]]></summary>
    <content type="html" xml:base="http://blakeley.com/blogofile/2012/03/30/albummixer-v1.11"><![CDATA[<p>AlbumMixer v1.11 fixes some minor bugs,
and should be better behaved with iTunes Match.
If you see any problems with this release,
please use <code>Settings &gt; Report a Problem</code> from within the app.
I will also read comments posted here.</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://blakeley.com/blogofile</uri>
    </author>
    <title type="html"><![CDATA[Directory Assistance]]></title>
    <link rel="alternate" type="text/html" href="http://blakeley.com/blogofile/2012/03/19/directory-assistance" />
    <id>http://blakeley.com/blogofile/2012/03/19/directory-assistance</id>
    <updated>2012-03-19T12:34:56Z</updated>
    <published>2012-03-19T12:34:56Z</published>
    <category scheme="http://blakeley.com/blogofile" term="MarkLogic" />
    <summary type="html"><![CDATA[Directory Assistance]]></summary>
    <content type="html" xml:base="http://blakeley.com/blogofile/2012/03/19/directory-assistance"><![CDATA[<p>For a long time now, MarkLogic Server has implemented two distinct features
that are both called "directories". This causes confusion, especially since one
of these features scales well and the other often causes scalability problems.
Let's try to distinguish between these two features,
and talk about why they both exist.</p>
<p>Directories were first introduced to accomodate WebDAV.
Since WebDAV clients treat the database as if it were a filesystem,
they expect document URIs with the solidus, or <code>/</code>,
to imply directory structure. That's one feature called "directories":
if you insert a document with the URI <code>/a/b/c.xml</code>, you can call
<code>xdmp:directory('/a/b/', '1')</code> to select that document -
and any other document with the same URI prefix. These URI prefixes
are indexed in much the same way that document URIs and collection URIs
are indexed, so queries are "searchable" and scale well.</p>
<p>This "implied directory structure" works with any database configuration.
You do not need <code>directory-creation=automatic</code>
to use the <code>cts:directory-query</code> and <code>xdmp:directory</code> functions.</p>
<script src="https://gist.github.com/2127471.js?file=gistfile1.xq"></script>

<p>This returns a query plan in XML:</p>
<script src="https://gist.github.com/2127484.js?file=gistfile1.xml"></script>

<p>But WebDAV clients expect more than just directory listings.
They also want to lock documents and directories.
It is easy to understand document locking: the idea here is that
a WebDAV-aware editor might lock a document, copy it to the local filesystem
for editing, and copy it back to the server when the editing session ends.
It may be less clear that a WebDAV client sometimes needs to lock directories,
but it does.</p>
<p>Directory locking is implemented using special directory fragments.
There are no documents associated with these properties,
so they are sometimes called "naked properties."
Here is an example.</p>
<script src="https://gist.github.com/2127498.js?file=gistfile1.xq"></script>

<p>Once this update has committed to the database,
we can query the directory fragment.</p>
<script src="https://gist.github.com/2127503.js?file=gistfile1.xq"></script>

<script src="https://gist.github.com/2127509.js?file=gistfile1.xml"></script>

<p>Once you have a directory fragment, you have something that the database
can lock for WebDAV clients. It's rare for anything else
to use this behavior, but <code>xdmp:lock-acquire</code> is available for custom
content management applications.</p>
<p>Earlier I mentioned that there are two kinds of "directories",
one that scales well and one that sometimes causes problems.
I wrote that queries based on directory URIs scale well,
so you might guess that directory fragments sometimes cause problems.
That's correct, and it results from a database feature called
"automatic directory creation".</p>
<p>When automatic directory creation is enabled - as it is by default -
the database will ensure that directory fragments exist for every
implied directory in the URI for every new or updated document.
The document URI <code>/a/b/c.xml</code> implies a directory fragment
for <code>/</code>, <code>/a/</code>, and <code>/a/b/</code>. So the database will ensure that these exist
whenever a request updates <code>/a/b/c.xml</code>.</p>
<p>So what happens when one request updates <code>/a/b/c.xml</code>
and another request updates <code>/a/b/d.xml</code>?</p>
<p>Both requests try to ensure that there are directory fragments
for <code>/</code>, <code>/a/</code>, and <code>/a/b/</code>. This causes lock contention.
The same problem shows up if another request is updating <code>/fubar.xml</code>,
because both queries look for the <code>/</code> directory fragment.
The situation gets worse as concurrency increases.
It gets even worse if "maintain directory last-modified" is enabled,
because the directory fragments have to be updated too.
But happily that feature is not enabled by default.</p>
<p>The solution to this problem is simple. In my experience
at least 80% of MarkLogic Server customers do not use WebDAV,
so they do not need automatic directory creation. Instead,
they can set directory creation to "manual".
Do this whenever you create a new database,
or script it using <code>admin:database-set-directory-creation</code>.</p>
<p><img alt="admin UI screen shot" src="/blogofile/images/0109.directory-assistance.admin-UI.png" title="setting directory creation in the admin UI" /></p>
<p>If you do use WebDAV, try to limit its scope. Perhaps you can get by
with a limited number of predefined WebDAV directories,
which you create manually using <code>xdmp:directory-create</code>
as part of your application deployment.
Or perhaps you only use WebDAV for your XQuery modules,
which only contains a few hundred or at most a few thousand documents.
In that case you can use automatic directory creation without a problem.</p>
<p>Generally speaking, really large databases don't use WebDAV anyway.
"Big content" databases, with hundreds of millions or billions of documents,
tend to be much to large for WebDAV to be useful.
For smaller databases where WebDAV is useful,
automatic directory creation is fine.</p>
<p>Sometimes it is useful to set "directory-creation" to "manual-enforced".
With this configuration you will see an <code>XDMP-PARENTDIR</code> error
whenever your code tries to insert a document
with an implied directory structure
that does not have corresponding directory fragments.
But this feature is rarely used.</p>
<p>To sum up, directory URIs are highly scalable and very useful,
and are always indexed. Your code can call <code>xdmp:directory</code>
with any database settings.
The default "automatic directory creation" feature creates directory fragments,
which can be a bottleneck for large databases.
Most applications are better off with "directory-creation" set to "manual".</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://blakeley.com/blogofile</uri>
    </author>
    <title type="html"><![CDATA[Let-free Style and Streaming]]></title>
    <link rel="alternate" type="text/html" href="http://blakeley.com/blogofile/2012/03/19/let-free-style-and-streaming" />
    <id>http://blakeley.com/blogofile/2012/03/19/let-free-style-and-streaming</id>
    <updated>2012-03-19T12:34:56Z</updated>
    <published>2012-03-19T12:34:56Z</published>
    <category scheme="http://blakeley.com/blogofile" term="XQuery" />
    <category scheme="http://blakeley.com/blogofile" term="MarkLogic" />
    <summary type="html"><![CDATA[Let-free Style and Streaming]]></summary>
    <content type="html" xml:base="http://blakeley.com/blogofile/2012/03/19/let-free-style-and-streaming"><![CDATA[<p>If you are familiar with Lisp or Scheme, you know that a function call can
replace a variable binding, and function calls can also replace most loops.
This is also true in XQuery.</p>
<script src="https://gist.github.com/2127325.js?file=gistfile1.xq"></script>

<script src="https://gist.github.com/2127351.js?file=gistfile1.txt"></script>

<p>In XQuery this leads to a style of coding that I call "let-free".
In this style, there are no FLWOR expressions.
Really this is "FLWOR-free", not "let-free",
but that's too much of a mouthful for me.</p>
<p>But why would you write let-free code?</p>
<p>The answer is scalability - you knew it would be, right?
This breaks out into concurrency and streaming.
Let's talk about concurrency first.
In the MarkLogic Server implementation of XQuery,
every <code>let</code> is evaluated in sequence. However, other expressions
are evaluated lazily with concurrency-friendy "future values".
So a performance-critical single-threaded request can sometimes
benefit from let-free style. You can see this technique in use
in some of my code:
the <a href="github.com/marklogic/semantic">semantic library</a>
or the <a href="github.com/mblakele/task-rebalancer">task-server forest rebalancer</a>.
Both of these projects try to benefit from multi-core CPUs.</p>
<p>The let-free style can also help with query scalability
by allowing the results to stream,
rather than buffering the entire result sequence.
If you need to export large result sets, for example,
this technique can help avoid <code>XDMP-EXPNTREECACHEFULL</code> errors.
Those errors result when your query's working set is too large
to fit in the expanded tree cache, a sort of scratch space for XML trees.
But streaming results don't have to fit into the cache.</p>
<p>For example, let's suppose you need to list every document URI in the database.
But you do not have the URI lexicon enabled,
and you cannot reindex to create it.</p>
<script src="https://gist.github.com/2127363.js?file=gistfile1.xq"></script>

<script src="https://gist.github.com/2127371.js?file=gistfile1.xq"></script>

<p>Note that nested evaluations cannot stream, either. So even a let-free query
may throw XDMP-EXPNTREECACHEFULL in cq or another development tool.
To test this query, use an http module instead.
This is ideal for web service implementations too.</p>
<p>In this example we used function mapping, a MarkLogic extension to XQuery 1.0.
If a function takes a single argument but is called using a sequence,
the evaluator simply maps the sequence to multiple function calls.
This is somewhat faster than a FLWOR, and it can stream.</p>
<p>Besides using function mapping, let-free style can use XPath steps.
However, this technique only works for sequences of nodes.</p>
<script src="https://gist.github.com/2127388.js?file=gistfile1.xq"></script>

<p>While these techniques are useful, they can make for code that is
hard to read and tricky to debug. Function mapping is especially prone to errors
that are difficult to diagnose. If a function signature specifies an argument
without a quantifier or with the <code>+</code> quantifier,
and the runtime argument is empty, the function will not be called at all.
This is surprising, since normally the function would be called
and would cause a strong typing error.</p>
<script src="https://gist.github.com/2127394.js?file=gistfile1.xq"></script>

<script src="https://gist.github.com/2127403.js?file=gistfile1.xq"></script>

<p>The first expression returns the empty sequence,
while the second throws the expected strong typing error <code>XDMP-AS</code>.
This behavior is annoying, but in some applications
the benefits of function mapping outweigh this drawback.
We can make debugging easier if we weaken the function signature
to <code>document-node()?</code> so that the function will be called
even when the argument is empty. If needed, we can include an explicit check
for empty input too.</p>
<p>Another let-free trick is to use module variables.
These act much like <code>let</code> bindings, but they can stream.</p>
<script src="https://gist.github.com/2127416.js?file=gistfile1.xq"></script>

<p>This example is a bit contrived, since the module variable doesn't add anything.
But if you find yourself struggling to refactor a <code>let</code> as a function call
or an XPath step, consider using a module variable.
Module variables are also excellent tools for avoiding repeated work,
since the right-hand expression is evaluated lazily and is never
evaluated more than once. If the evaluation does not use the module variable,
then the right-hand expression is never evaluated.
In contrast, the right-expression of a <code>let</code> is evaluated
even when the <code>return</code> does not use its value.</p>
<p>As always, do not optimize code unless there is a problem to solve.
There are also some situations where the let-free style isn't appropriate.
Aside from making your code harder to read and more difficult to debug,
let-free style simply doesn't work in situations where your FLWOR
would have an <code>order by</code> clause.
And after all, streaming won't work for that case anyway.
The evaluator can't sort the result set without buffering it first.</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://blakeley.com/blogofile</uri>
    </author>
    <title type="html"><![CDATA[MrCombo v1.1]]></title>
    <link rel="alternate" type="text/html" href="http://blakeley.com/blogofile/2012/01/07/mrcombo-v1.1" />
    <id>http://blakeley.com/blogofile/2012/01/07/mrcombo-v1.1</id>
    <updated>2012-01-07T11:00:00Z</updated>
    <published>2012-01-07T11:00:00Z</published>
    <category scheme="http://blakeley.com/blogofile" term="iOS" />
    <summary type="html"><![CDATA[MrCombo v1.1]]></summary>
    <content type="html" xml:base="http://blakeley.com/blogofile/2012/01/07/mrcombo-v1.1"><![CDATA[<p>MrCombo v1.1 is now available in the iOS App Store.
As with v1.0, this app lets you build lists in a two-level hierarchy:
<code>combo &gt; group &gt; item</code>. Then MrCombo can shuffle your items to create a mix.
Sample data includes ordering a pizza, picking an outfit,
and picking a traditional shave with a double-edge (DE) razor.
These are samples: edit them, or create your own combinations.</p>
<p>New features in v1.1 include:</p>
<ul>
<li>Lock items in a mix, so you can have partly-random mixes.</li>
<li>Save a mix to your local history.</li>
<li>Attach a photo to a saved mix.</li>
<li>Share saved mixes via clipboard, email, or WordPress.</li>
<li>Bulk add several items at once into a group.</li>
<li>Import and export combos to the clipboard.</li>
<li>Import and export combos to Dropbox.</li>
</ul>
<p>For now MrCombo is free, but if I keep adding more features that may change.</p>
<p>You can <a href="/ios/mrcombo">read more about MrCombo</a>
or <a href="http://itunes.apple.com/us/app/mrcombo/id489265191">get MrCombo on iTunes</a>.</p>
<p>If you run into problems with MrCombo, you can reach me through the App Store
or post a comment right here.</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://blakeley.com/blogofile</uri>
    </author>
    <title type="html"><![CDATA[Conditional Profiling for MarkLogic]]></title>
    <link rel="alternate" type="text/html" href="http://blakeley.com/blogofile/2011/12/14/conditional-profiling-for-marklogic" />
    <id>http://blakeley.com/blogofile/2011/12/14/conditional-profiling-for-marklogic</id>
    <updated>2011-12-14T15:16:17Z</updated>
    <published>2011-12-14T15:16:17Z</published>
    <category scheme="http://blakeley.com/blogofile" term="XQuery" />
    <category scheme="http://blakeley.com/blogofile" term="MarkLogic" />
    <summary type="html"><![CDATA[Conditional Profiling for MarkLogic]]></summary>
    <content type="html" xml:base="http://blakeley.com/blogofile/2011/12/14/conditional-profiling-for-marklogic"><![CDATA[<p>Today I pushed <a href="https://github.com/mblakele/cprof">cprof</a> to GitHub.
This XQuery library helps application developers
who need to retrofit existing applications with profiling capabilities.
Just replace all your existing calls to
<code>xdmp:eval</code>, <code>xdmp:invoke</code>, <code>xdmp:value</code>,
<code>xdmp:xslt-eval</code>, and <code>xdmp:xslt-eval</code> with corresponding <code>cprof:</code> calls.
Add a little logic around <code>cprof:enable</code> and <code>cprof:report</code>, and you are done.</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://blakeley.com/blogofile</uri>
    </author>
    <title type="html"><![CDATA[MrCombo v1.0]]></title>
    <link rel="alternate" type="text/html" href="http://blakeley.com/blogofile/2011/12/13/mrcombo-v1.0" />
    <id>http://blakeley.com/blogofile/2011/12/13/mrcombo-v1.0</id>
    <updated>2011-12-13T14:15:16Z</updated>
    <published>2011-12-13T14:15:16Z</published>
    <category scheme="http://blakeley.com/blogofile" term="iOS" />
    <summary type="html"><![CDATA[MrCombo v1.0]]></summary>
    <content type="html" xml:base="http://blakeley.com/blogofile/2011/12/13/mrcombo-v1.0"><![CDATA[<p>I have submitted a new iOS application to Apple: MrCombo.
This app lets you build lists in a two-level hierarchy:
combo &gt; group &gt; item. Then you can shuffle the items to mix it up.
Sample data includes ordering a pizza and picking an outfit,
but you are meant to create your own combinations.</p>
<p>Yes, it's a bit silly. But I find it fun and useful
so I thought I would release it.
For now MrCombo is free, but if I keep adding more features that may change.</p>
<p>You can <a href="/ios/mrcombo">read more about MrCombo</a>
or <a href="http://itunes.apple.com/us/app/mrcombo/id489265191">get MrCombo on iTunes</a>.</p>
<p>If you run into problems with MrCombo, you can reach me through the App Store
or post a comment right here.</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://blakeley.com/blogofile</uri>
    </author>
    <title type="html"><![CDATA[AlbumMixer v1.10 and iTunes Match]]></title>
    <link rel="alternate" type="text/html" href="http://blakeley.com/blogofile/2011/11/28/albummixer-v1.10-and-itunes-match" />
    <id>http://blakeley.com/blogofile/2011/11/28/albummixer-v1.10-and-itunes-match</id>
    <updated>2011-11-28T13:00:00Z</updated>
    <published>2011-11-28T13:00:00Z</published>
    <category scheme="http://blakeley.com/blogofile" term="iOS" />
    <summary type="html"><![CDATA[AlbumMixer v1.10 and iTunes Match]]></summary>
    <content type="html" xml:base="http://blakeley.com/blogofile/2011/11/28/albummixer-v1.10-and-itunes-match"><![CDATA[<p>I am hearing early reports that AlbumMixer v1.10 has problems
with iTunes Match and playlists. So far I haven't been able to reproduce this,
but I am working on it. If you see any problems and can provide details,
please comment here.</p>
<p><strong>Update</strong>: Based on additional user reports,
plus a lack of crash reports from Apple, I think this is an iOS or iCloud issue.
Because of this and other current issues being discussed
on <a href="https://discussions.apple.com/community/itunes/itunes_match">Apple forums</a>
<strong>I cannot recommend signing up for iTunes Match at this time</strong>.
If you decide to risk it, start by backing up your entire iTunes library.
Apple seems to be refunding subscription fees to some users,
but that won't be much of a consolation if you lose a large media library.</p>]]></content>
  </entry>
  <entry>
    <author>
      <name></name>
      <uri>http://blakeley.com/blogofile</uri>
    </author>
    <title type="html"><![CDATA[Testing AWS EC2 Instances for Co-Residence]]></title>
    <link rel="alternate" type="text/html" href="http://blakeley.com/blogofile/2011/11/21/testing-aws-ec2-instances-for-co-residence" />
    <id>http://blakeley.com/blogofile/2011/11/21/testing-aws-ec2-instances-for-co-residence</id>
    <updated>2011-11-21T13:00:00Z</updated>
    <published>2011-11-21T13:00:00Z</published>
    <category scheme="http://blakeley.com/blogofile" term="AWS" />
    <summary type="html"><![CDATA[Testing AWS EC2 Instances for Co-Residence]]></summary>
    <content type="html" xml:base="http://blakeley.com/blogofile/2011/11/21/testing-aws-ec2-instances-for-co-residence"><![CDATA[<p>Have you ever thought about setting up a cluster of software nodes
using Amazon's EC2 infrastructure? You may have wondered what happens
if Amazon's underlying hardware should fail.
That hardware runs the hypervisor for your EC2 instance,
and if it fails so does your instance. If you have a cluster of N nodes,
what happens to the cluster?</p>
<p>Most cluster software includes some mechanism to handle host failures.
But the cluster was usually designed to run on real hosts, not virtual machines.
In most cases a hardware or software fault should take out exactly one host.
But in a virtualized environment the same fault might affect
more than one virtual machine. This is especially true in a cloud environment
like EC2, where you have no visibility into the hypervisor.</p>
<p>At first this may not seem to be a problem. If you create four EC2 instances
at the same time, they usually seem to start on different hypervisors.
So a hypervisor failure will only affect one instance,
and the cluster failover mechanisms will operate as usual.</p>
<p>But when an instance does fail, you will want to replace it. How can you ensure
that the replacement instance won't be co-resident
with any of your existing instances?
If the replacement instance is co-resident with an existing cluster instance,
and another hypervisor fault affects both instances, the cluster will go down.
Depending on the circumstances, you may lose data too.</p>
<p>So how can we prevent this? One idea is to include a pool of spare instances
when we create the cluster instances. But this makes the cluster more expensive.
We cannot stop the spare instances either, because when we start them again
they may end up co-resident with another instance. Over time we may also
exhaust this pool of spares, leaving us with the original problem again.
How can we avoid co-resident cluster instances?</p>
<p>If we could detect co-residence, we could simply create instances
until we get one that is not co-resident. This approach is crude,
but should be effective.</p>
<ol>
<li>Create instance (or start existing stopped instance).</li>
<li>Check co-residence for each existing instance.</li>
<li>If co-resident, stop the instance and return to step #1.</li>
</ol>
<p>Any instance that makes it past step #3 is not co-resident
with any existing member of the cluster instance, and can join the cluster.
This leads to a new problem: how can we test for co-residence?</p>
<p>AWS does not appear to provide an easy way to do this.
Allowing instances visibility into the hypervisor could lead to security holes.
This problem has been discussed by
<a href="http://www.cs.tau.ac.il/~tromer/papers/cloudsec.pdf">Ristenpart, Tromer, et al</a>.
My own experiments suggest that AWS has changed its network topology since 2009,
but I did find a technique that seems to work.</p>
<p>From what I can tell, each AWS hypervisor acts as a gateway
for its guest instances. Each guest instance runs on its own subnet.
So knowing the IP address alone tells us nothing,
but knowing the network hops from one instance to another could be revealing.</p>
<p>If each hypervisor acts as a gateway, then packets sent between
two co-resident instances will always need exactly two hops.
Packets sent between instances that are not co-resident will need more hops.</p>
<script src="https://gist.github.com/1383958.js"> </script>

<p>We can conclude that ip-10-87-117-148 and ip-10-87-69-9 are co-resident.</p>
<script src="https://gist.github.com/1383949.js"> </script>

<p>We can conclude that ip-10-91-9-230 and ip-10-87-117-148 are <em>not</em> co-resident.</p>
<p>Note that this technique may not be foolproof.
If Amazon believes that this information compromises security,
they could probably reconfigure their hypervisors so that new instances
would hop through a random number of extra gateways. This would add some latency
to the network, but more importantly would keep the guest instance
from using this technique to determine whether or not it is co-resident
with some other instance. That would be a shame for those of us
using AWS for highly-available cluster applications...
unless AWS also added a <em>supported technique</em> for avoiding co-residence.</p>]]></content>
  </entry>
</feed>

