Server method takes a lot of time if it calls Account.createUser within


#1

I have a server method:

createDemoUser: function () {
        let start = new Date();
        console.log("createDemoUser entering", new Date() - start);
        let id = new Date().valueOf().toString();
        var userId = Accounts.createUser({
           username: id,
           email: id,
           password: id,
           profile: {firstName: id}
       });
        console.log("createDemoUser, created", new Date() - start);
        return id;
    }

This method is called on a client. The callback of Meteor.call(“createDemoUser”) is just Meteor.loginWithPassword().
It is strange - the server method execution is very long and callback on the client is called after 15 sec.:
But on the server method executed quickly, there is the log from the server:

[Server IP] createDemoUser entering 0
[Server IP] createDemoUser, created 195

My investigations is the following:

  1. In development (the server and the client on the same computer) the method calling takes appr. 1 sec.
  2. In production (the server located on the remote computer) the method takes appr. 15 sec (sic!).
  3. In production, without calling of Accounts.createUser the method calling takes few milliseconds.

I had suggested that it may strange behaviour of long execution of the server method and DDP, and I inserted long computation (appr. 4 sec). No, the method calling takes same time as long computation.

Any ideas are welcome!