Dubbo service registration is too slow

problem description

when we were doing public offering, we found that the dubbo registration service was too slow and it took a long time to start the service. Lazy loading will lead to a bad customer experience. After looking at the source code, it is found that dubbo registration is a lock registration method.

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (please do not replace the code with a picture)
Registration Log
2018-09-28 10 com.alibaba.dubbo.config.AbstractConfig 34mod 29084 [com.alibaba.dubbo.config.AbstractConfig]-[DUBBO] Refer dubbo service com.fulihui.sign.facade.admin.SignRemarkAdminService from url zookeeper://192.168.1.45:2181/com.alibaba.dubbo.registry.RegistryService?anyhost=true&application=com.fulihui.kirin.promobizmanage&check=false&default.check=false&default.lazy=true&default.retries=0 & default.timeout=5000&default.validation=true&default.version=1.0.0&dubbo=2.8.4&generic=false&interface=com.fulihui.sign.facade.admin.SignRemarkAdminService&methods=selectLimitPage, Update,insert,selectById,insertOrUpdate&pid=1932&revision=1.0.0&serialization=json&side=consumer×tamp=1538102068414&version=1.0.0, dubbo version: 2.8.4, Current host: 192.168.4.140
2018-09-28 10 Fringe 34 DUBBO 29154 [alibaba.dubbo.registry.zookeeper.ZookeeperRegistry]-[DUBBO] Register: consumer://192.168.4.140/com.fulihui.sign.facade.admin.SignInStatAdminService?application=com.fulihui.kirin.promobizmanage&category=consumers&check=false&default.check=false&default.lazy=true&default.retries=0&default.timeout=5000&default.validation=true&default.version=1.0.0&dubbo=2.8.4&interface=com.fulihui.sign.facade.admin.SignInStatAdminService&methods=querySignInStat & pid=1932&revision=1.0.0&side=consumer×tamp=1538102069150&version=1.0.0, Dubbo version: 2.8.4, current host: 192.168.4.140
2018-09-28 10 purge 34 alibaba.dubbo.registry.zookeeper.ZookeeperRegistry 29324 [alibaba.dubbo.registry.zookeeper.ZookeeperRegistry]-[DUBBO] Subscribe: consumer://192.168.4.140/com.fulihui.sign.facade.admin.SignInStatAdminService?application=com.fulihui.kirin.promobizmanage&category=providers,configurators, Routers&default.check=false&default.lazy=true&default.retries=0&default.timeout=5000&default.validation=true&default.version=1.0.0&dubbo=2.8.4&interface=com.fulihui.sign.facade.admin.SignInStatAdminService&methods=querySignInStat&pid=1932&revision=1.0.0&side=consumer×tamp=1538102069150&version=1.0.0, dubbo version: 2.8.4, current host: 192.168.4.140

what result do you expect? What is the error message actually seen?

URLListMap 

not as good as code like this, it is possible to register faster:


    private static final Lock INDEX_LOCK = new ReentrantLock();
private static Integer index = 0;

public static void main(String[] args) throws InterruptedException {
    final ArrayList<Integer> arrayList = new ArrayList<Integer>();
    Long count = 99999L;

    for (int i = 0; i < count; iPP) {
        arrayList.add(i);
    }

    CountDownLatch latch = new CountDownLatch(10);
    System.out.println("");
    for (int i = 0; i < 10; iPP) {
        new Thread(new Runnable() {
            
            @Override
            public void run() {
                while(true) {
                    try {
                        index = getIndex(arrayList.size()-1);
                        if(index == -1) {
                            break;
                        }
                        System.out.println(arrayList.get(index));
                    }finally {
                        latch.countDown();
                    }
                }
            }
        }).start();
        
        latch.await();
        
        System.out.println("OK");
    }
    
}

public static int getIndex(int count) {
    try {
        INDEX_LOCK.lock();
        
        if (index < count) {
            index =  index+ 1;
            return index;
        }
        return -1;
    } finally {
        INDEX_LOCK.unlock();
    }
}





Jul.20,2021
Menu