Slow AjaxResponse for node content I am using Drupal 8 so there is very little documentation or benchmarks, but I believe a route I have set up for ajax responses is not as performant as it could be.
This is the route:

next_node.ajax:
  path: '/node/{node}'
  defaults:
    _controller: '\Drupal\next_node\Controller\DefaultController::view'
  requirements:
    _permission: 'access content'
    _format: 'json'
    _access: 'TRUE'


And this is the controller:

class DefaultController extends EntityViewController {
  /**
   * {@inheritdoc}
   */
  public function view(EntityInterface $node, $view_mode = 'full', $langcode = NULL) {
    $build = parent::view($node);

    return new AjaxResponse(\Drupal::service('renderer')-&gt;renderPlain($build));
  }
}


I request the content through this function:

jQuery.get( "/node/2?_format=json", function( data ) { /* Do stuff */ });


Is it normal that it takes about a second on average to get a response? Where to optimize the code?
There are some different things which could be improved in your code, like using dependency injection, better naming etc, but none of these effect performance.

There are some different things which makes it quite trigger to give a good answer to this. Drupal 8 is still in beta and many performance optimizations are being made. The render cache and page cache should be usable in your case making subsequent requests cached and this a lot faster than the initial request. Being logged in / logged out make a big impact as Drupal has a hard time caching for logged in users, but this is nothing new.

That said, it still sounds a bit slow, but hardware, setup etc also have a lot to say.

So long story short, you can't really performance improve your code.