Datastore queries in Dataflow DoFn slow down pipeline when run in the cloud
<p>I am trying to enhance data in a pipeline by querying Datastore in a DoFn step. 
A field from an object from the Class <em>CustomClass</em> is used to do a query against a Datastore table and the returned values are used to enhance the object. </p>

<p>The code looks like this:</p>

<pre><code>public class EnhanceWithDataStore extends DoFn&lt;CustomClass, CustomClass&gt; {

private static Datastore datastore = DatastoreOptions.defaultInstance().service();
private static KeyFactory articleKeyFactory = datastore.newKeyFactory().kind("article");

@Override
public void processElement(ProcessContext c) throws Exception {

    CustomClass event = c.element();

    Entity article = datastore.get(articleKeyFactory.newKey(event.getArticleId()));

    String articleName = "";
    try{
        articleName = article.getString("articleName");         
    } catch(Exception e) {}

    CustomClass enhanced = new CustomClass(event);
    enhanced.setArticleName(articleName);

    c.output(enhanced);
}
</code></pre>

<p>When it is run locally, this is fast, but when it is run in the cloud, this step slows down the pipeline significantly. What's causing this? Is there any workaround or better way to do this? </p>

<p>A picture of the pipeline can be found here (the last step is the enhancing step):
<a href="https://i.stack.imgur.com/y82Dw.png" rel="nofollow">pipeline architecture</a></p>