How to make mymodule_preprocess_node run only once?
I found the issue. As @Kevin mentioned, it was being called for every node being rendered. I added a condition to check the view more as well and it is being called just one time now. 

function mymodule_preprocess_node(&amp;$variables) {
  $node = $variables['node'];
  if(isset($node-&gt;get('field_link')) &amp;&amp; $variables['elements']['#view_mode'] == 'my_view_mode') {
    // perform some logic. 

   ksm('in here'); // printed once as expected 
  }
}