phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (PHOENIX-3654) Load Balancer for thin client
Date Mon, 24 Jul 2017 15:34:01 GMT


ASF GitHub Bot commented on PHOENIX-3654:

Github user joshelser commented on a diff in the pull request:
    --- Diff: phoenix-load-balancer/src/main/java/org/apache/phoenix/queryserver/register/
    @@ -0,0 +1,72 @@
    + *
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.phoenix.queryserver.register;
    +import org.apache.commons.logging.Log;
    +import org.apache.commons.logging.LogFactory;
    +import org.apache.curator.framework.CuratorFramework;
    +import org.apache.curator.framework.CuratorFrameworkFactory;
    +import org.apache.curator.retry.ExponentialBackoffRetry;
    +import org.apache.curator.utils.CloseableUtils;
    +import org.apache.phoenix.loadbalancer.service.LoadBalanceZookeeperConf;
    +import org.apache.phoenix.queryserver.server.QueryServer;
    +import org.apache.zookeeper.CreateMode;
    +import java.nio.charset.StandardCharsets;
    +public class ZookeeperRegistry implements Registry {
    +    protected static final Log LOG = LogFactory.getLog(QueryServer.class);
    +    private CuratorFramework client;
    +    public ZookeeperRegistry(){}
    +    @Override
    +    public  void registerServer(LoadBalanceZookeeperConf configuration, int pqsPort,
    +                                String zookeeperConnectString, String pqsHost)
    +            throws Exception {
    +        this.client = CuratorFrameworkFactory.newClient(zookeeperConnectString,
    +                new ExponentialBackoffRetry(1000,10));
    +        this.client.start();
    +        HostAndPort hostAndPort = HostAndPort.fromParts(pqsHost,pqsPort);
    +        String path = configuration.getFullPathToNode(hostAndPort);
    +        String node = hostAndPort.toString();
    +        this.client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(path
    +                ,node.getBytes(StandardCharsets.UTF_8));
    +        Stat stat = this.client.setACL().withACL(configuration.getAcls()).forPath(path);
    +        if (stat != null) {
    +  " node created with right ACL");
    +        }
    +        else {
    +            LOG.error("could not create node with right ACL. So, system would exit now.");
    +            System.exit(-1);
    --- End diff --
    Calling `System.exit(-1)` is pretty brutal for anyone trying to integrate with your software
    Throwing a RuntimeException would be nicer.

> Load Balancer for thin client
> -----------------------------
>                 Key: PHOENIX-3654
>                 URL:
>             Project: Phoenix
>          Issue Type: New Feature
>    Affects Versions: 4.8.0
>         Environment: Linux 3.13.0-107-generic kernel, v4.9.0-HBase-0.98
>            Reporter: Rahul Shrivastava
>            Assignee: Rahul Shrivastava
>         Attachments: LoadBalancerDesign.pdf, Loadbalancer.patch
>   Original Estimate: 240h
>  Remaining Estimate: 240h
> We have been having internal discussion on load balancer for thin client for PQS. The
general consensus we have is to have an embedded load balancer with the thin client instead
of using external load balancer such as haproxy. The idea is to not to have another layer
between client and PQS. This reduces operational cost for system, which currently leads to
delay in executing projects.
> But this also comes with challenge of having an embedded load balancer which can maintain
sticky sessions, do fair load balancing knowing the load downstream of PQS server. In addition,
load balancer needs to know location of multiple PQS server. Now, the thin client needs to
keep track of PQS servers via zookeeper ( or other means). 
> In the new design, the client ( PQS client) , it is proposed to  have an embedded load
> Where will the load Balancer sit ?
> The load load balancer will embedded within the app server client.  
> How will the load balancer work ? 
> Load balancer will contact zookeeper to get location of PQS. In this case, PQS needs
to register to ZK itself once it comes online. Zookeeper location is in hbase-site.xml. It
will maintain a small cache of connection to the PQS. When a request comes in, it will check
for an open connection from the cache. 
> How will load balancer know load on PQS ?
> To start with, it will pick a random open connection to PQS. This means that load balancer
does not know PQS load. Later , we can augment the code so that thin client can receive load
info from PQS and make intelligent decisions.  
> How will load balancer maintain sticky sessions ?
> While we still need to investigate how to implement sticky sessions. We can look for
some open source implementation for the same.
> How will PQS register itself to service locator ?
> PQS will have location of zookeeper in hbase-site.xml and it would register itself to
the zookeeper. Thin client will find out PQS location using zookeeper.

This message was sent by Atlassian JIRA

View raw message