proxy中elasticjob探活调度分片问题

方便更快捷的说明问题,可以按需填写(可删除)


proxy 5.1版本这里的探活只有一个分片,这种情况如果proxy后端管理很多的mysql集群,这些探活任务都会落到一个proxy实例上,这个proxy实例相对其他几个实例压力是否会很大?

直接用elasticjob试验过,试验了下多个不同的jobName,shardingTotalCount为1时,部署多台机器时观察下来会由同一台机器执行,这样jobName之间没有均衡地负载到不同机器,代码如下

public class ElasticjobExample {
    public static void main(String[] args) throws Exception {
        final CoordinatorRegistryCenter registryCenter = createRegistryCenter();
        for (int i = 0; i < 3; i++) {
            String schemaName = "seo_aws_mysql_" + i;
            ScheduleJobBootstrap bootstrap = new ScheduleJobBootstrap(registryCenter, new HeartbeatJob(schemaName), JobConfiguration.newBuilder("exampleJob-" + schemaName, 1).cron("0/5 * * * * ?").build());
            bootstrap.schedule();
        }
        final CountDownLatch countDownLatch = new CountDownLatch(1);
        countDownLatch.await();
    }

    private static CoordinatorRegistryCenter createRegistryCenter() {
        CoordinatorRegistryCenter coordinatorRegistryCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration("node1:2181", "learn-elasticjob"));
        coordinatorRegistryCenter.init();
        return coordinatorRegistryCenter;
    }

    @AllArgsConstructor
    @Data
    public static class HeartbeatJob implements SimpleJob {
        private String schemaName;

        @Override
        public void execute(ShardingContext shardingContext) {
            System.out.println(schemaName + " shardingItem: " + shardingContext.getShardingItem() + " myjob " + Thread.currentThread().getName());
        }
    }
}

还有一个建议,这个jobname是不是变成type+schema+groupname会更好一些,现在如果groupname一致的话就无法区分了

这个欢迎提交 PR 来增加下它.

京ICP备2021015875号