dubbo: Server side loadbalance problem
- I have searched the issues of this repository and believe that this is not a duplicate.
- I have checked the FAQ of this repository and believe that this is not a duplicate.
Environment
- Dubbo version: 2.6.2
- Operating System version: win7
- Java version: 1.8
Step to reproduce this issue
Problem one
I want to test pseudo cluster, I create service like follow code :
public interface DemoService
{
String sayHello(String name);
}
implement service interface as follows, both loadbalance strategies are random:
@Service(timeout = 5000, loadbalance="random")
public class DemoServiceImpl implements DemoService
{
@Override
public String sayHello(String name)
{
return "Service1 -> Hello " + name;
}
}
@Service(timeout = 5000, loadbalance="random")
public class DemoServiceImpl2 implements DemoService
{
@Override
public String sayHello(String name)
{
return "Service2 -> Hello " + name;
}
}
I start one appliction to test it.
Expected Result
- random return “Service1” and “Service2” .
Actual Result
- alway return “Service2”
Problem two
change one implement loadbalance stragy as follow:
@Service(timeout = 5000, loadbalance="consistenthash")
public class DemoServiceImpl implements DemoService
{
@Override
public String sayHello(String name)
{
return "Service1 -> Hello " + name;
}
}
Expected Result
- random return “Service1” and “Service2” .
Actual Result
- alway return “Service1”
Question
I don’t know how dubbo it works. but it is very strange , it always use consistenthash stragy.
Dubbo provide client and server side loadbalance stragy , Who is at work.
As I know,dubbo has no central node coordinator, may be is client side effect. If remove server side loadblance stragy or improve it ?
could not provid unique way to use loadbalance
- Single loadbalance stragy
- Mixed loadbalance stragy
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 21 (11 by maintainers)
@freeseawind GOT it.
notice the last attribute
timestampis different, it means that the two implementations both trigger the registry operation. So in the zookeeper, you can see two providers, while in the spring IOC context, it also has two implementations.The problem is that Dubbo invoker can not distinguish the two provider because their main attributes are the same. While dubbo try to find the ref in the Spring IOC context, one of the them is always selected.
I think that it is dubbo user’s responsibility to set enough info if two providers are exist in the same context.
more details can reference the
com.alibaba.dubbo.config.spring.ServiceBean. It implementsInitializingBeanandApplicationListener, you can know the initialization process by debuging into two methodafterPropertiesSet()andonApplicationEvent().