How to properly setup Vibe-d server with mysql-native

I have vibe-d program that is used as a proxy for links. I use mysql-native to connect to SQL. It works, but the service dies after 20s - 2mins on higher traffic. I didn't see any specific error besides: core.exception.AssertError. This got me thinking if I have everything set up properly. I didn't find any example on how to set a project like this.

This is a VERY simplified version of my app. Is this the right way to connect to MySQL in Vibe-d project? I create a mysql pool in Proxyd class and then open new connection in every action by lockConnection.

void main()
  Proxyd proxy = new Proxyd(dbConfig);
  auto settings = new HTTPServerSettings;
  HTTPListener http_listener = listenHTTP(settings, proxy.getRouter());

class Proxyd
  URLRouter router;
  MySQLPool db_pool;

  this(Node dbConfig)
    router = new URLRouter;
    router.get("/link", &link);
    db_pool = new MySQLPool(host,username,password,database,port);

  void link(HTTPServerRequest request, HTTPServerResponse response)
    db = db_pool.lockConnection();
    ResultRange rows = db.query("..")


  • I'm not sure exactly, but it may be due to that vibe.core.connectionpool cannot be shared across worker threads.

    This would be work.

    MySQLPool pool;  // per threads, on TLS.
    static this() {
        pool = new MySQLPool(...);