6ms sounds about right for a non-warmed up vm. I have no idea why the embedded case would take 100ms though. Perhaps use strace or similar on the vm process to see what's going on under the covers? I'm assuming you're not doing something crazy in the embedded vm, and that it's not gcing/swapping for long periods of time (which might be an invalid assumption, so you should check that as well).
Patrick On Fri, Jun 8, 2012 at 2:58 PM, David Nickerson <[email protected]> wrote: > I have a speed test where I create and delete a single znode many times, > sequentially. If I connect to an embedded ZooKeeper server on the same > machine, each create/delete cycle takes over 100 ms. However, if I connect > to a non-embedded ZooKeeper server on the same machine, each > create/delete cycle takes only 6 ms. > > This is the code that I use to start the embedded server: > > package main; > > import java.io.IOException; > > import org.apache.zookeeper.server.ServerConfig; > import org.apache.zookeeper.server.ZooKeeperServerMain; > import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; > > public class ZooServer extends ZooKeeperServerMain implements Runnable { > private static ZooServer zooServer; > private static ServerConfig config; > > public static void start(String configPath) { > config = new ServerConfig(); > try { > config.parse(configPath); > } catch (ConfigException e) { > e.printStackTrace(); > } > zooServer = new ZooServer(); > (new Thread(zooServer)).start(); > } > > public static void stop() { > zooServer.shutdown(); > } > > @Override > public void run() { > try { > zooServer.runFromConfig(config); > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > The config file looks like this: > tickTime=2000 > dataDir=ZooKeeper files > clientPort=2181 > > If you would like, I can share the testing classes. > > Anyone know why the embedded server is running so slowly?
