The past few years have witnessed significant growth in the use of distributed network analytics involving agile code, data and computational resources. In many such networked systems, for example, Internet of Things (IoT) , a large number of computational and storage resources are widely distributed in the physical world. These resources are accessed by various end users/applications that are also distributed over the physical space. Assigning users or applications to resources efficiently is key to the sustained high-performance operation of the system.
While in some applications the “service” occurs over a communication network, in others it occurs over a physical space. Examples of the former type of service include accessing storage resources over a wireless network to store files and requesting computational resources to run image processing tasks; whereas an example of the latter type of service is the arrival of ride-sharing vehicles to the user’s location over a road transportation network.
Not surprisingly, the relative spatial distribution of resources and users in the network plays an important role in determining the overall performance of the service. A key measure of performance is the average request distance, that is the average distance between a user and its allocated resource/service (where the distance is measured on the network). This directly translates to the user’s latency of accessing the service, which is arguably among the most important criteria in distributed service applications. An important practical constraint in such networks is finite service capacity. For example, in network analytics applications, a networked storage device can only support a finite number of concurrent users; similarly, a computational resource can only support a finite number of concurrent processing tasks. Likewise, in physical service applications like ride-sharing, a vehicle can pick up a finite number of passengers.
Therefore, a primary problem in such distributed service networks is to efficiently assign each user to a suitable resource such that the average request distance is minimized and no resource serves more users than its capacity. If the entire system is being managed by a single administrative entity such as a ride sharing service, or a datacenter network where analytics tasks are being assigned to available CPUs, there are economic benefits in minimizing the average request distance across all (user, resource) pairs, which is tantamount to minimizing the average delay in the system.
The general version of this capacitated assignment problem can be solved by modeling it as a minimum cost flow problem on graphs  and running the network simplex algorithm . However, if the network has a low-dimensional structure and some assumptions about the spatial distributions of users and resources hold, more efficient methods can be developed.
In this paper, we consider two one-dimensional network scenarios that motivate the study of this special case of the user-to-resource assignment problem.
The first scenario is of ride-hailing on a one-way street which allows vehicle traffic to run from right to left. If the vehicles of a ride-sharing company are distributed along the street at a certain time instant, and users equipped with smartphone ride-hailing apps request service, the system attempts to assign vehicles with spare capacity located towards the right of the users so as to minimize average “pick up” distance. Abadi et al.  introduced this problem and gave an optimal policy known as Unidirectional Gale-Shapley 222We rename queue matching defined in  as Unidirectional Gale-Shapley Matching to avoid overloading the term queue. matching (UGS), in which all users transmit rays of light toward their right in parallel and are matched with the vehicles that first receive the respective rays.
In this paper, we propose another optimal policy “Move to Right” policy (or MTR) which has the same “expected distance traveled by a request” (request distance) as UGS but has a lower variance. MTR sequentially allocates users to the geographically nearest available vehicle located to his/her right. If the locations of requesters and vehicles are modeled by independent Poisson processes, average request distance can be characterized in closed form by considering inter-user and inter-server distances as parameters of an M/M/1 temporal queue, or of a bulk service M/M/1 queue depending on server capacity, where capacity denotes the maximum number of users that can be handled by a server. We equate request distance in the spatial system to the expected sojourn time for the corresponding queuing model333Note that sojourn time is the sum of waiting and service times in a queue.. This natural mapping allows us to use well-known results from queueing theory to characterize request distances in closed form for a number of interesting situations beyond M/M/1 queues.
The second scenario involves distributed analytics in a convoy of vehicles with optional sensors and/or computing resource traveling on a road. The convoy is spatially distributed over a one-dimensional space and the communication between vehicles therein involves non-interfering single hop wireless transmission, also known as the direct transmission model 
. Vehicles have heterogeneous capabilities – those with sensing/imaging resources may or may not have sufficient computational resources to do the processing, whereas others with rich computational resources allow computational tasks (e.g., deep neural network based image classification) to be assigned to them. In this case, since no directionality restrictions are imposed on the allocation algorithms, computing the optimal assignment is not as simple as inMTR.
We explore the special structure of the one-dimensional topology to develop an optimal algorithm that assigns requester nodes to resource nodes such that the total cost of assignment is minimized. Although this has been recently solved for , the case is still open. Our algorithm solves this case with time complexity . If the locations of and are distributed according to independent Poisson processes, we show by simulation that the sizes of groups (i.e., contiguously allocated (requester, resource) pairs) that we encounter are small and do not depend on . Hence we conjecture without proof that the average running time of our optimal algorithm is much lower than the worst case of in such realistic circumstances and is likely to be . Note that other assignment algorithms in literature such as the Hungarian primal-dual algorithm and Agarwal’s variant  assume for general and Euclidean distance measures and hence applying those for the case would involve adding dummy user nodes far away. Thus in realistic resource rich environments, our optimal algorithm can be more efficient than these approaches.
Our contributions are summarized below:
Simple directional allocation policies such as: MTR and UGS for unidirectional assignment, and their queueing theoretic analysis yielding closed form expressions for request distance.
If the inter-requester and inter-resource distances are exponentially distributed, we model unidirectional policies using a temporal M/M/1 queue for basic assignment and using a bulk service M/M/1 queue for assignment under resource capacity constraints.
If the inter-requester distances are exponentially distributed but the inter-resource distances are generally distributed, we model the situation using an M/G/1 queue with the first customer having exceptional service time and derive expressions for exceptional service time under various inter-server distance distributions.
Analysis of request distance in closed form under general distance distributions when the inter-requester and inter-resource distributions have similar mean values.
An optimal algorithm for bidirectional assignment with time complexity , which can be better than known algorithms if or if the input distance distributions are Poisson.
A thorough numerical simulation study of five assignment schemes: UGS , MTR, nearest neighbor, stable assignment due to Gale and Shapley, and optimal assignment.
The paper is organized as follows. The next section discusses about the related literature. Section III contains some technical preliminaries. We show the equivalence of queue matching and MTR policy w.r.t expected request distance in Section IV
, and present results associated with the case when servers are poisson distributed in SectionV. We develop formulations for a general inter-server distance distribution in Section VI. The optimal allocation strategy with request distance as metric is presented in Section VII. We compare the performance of various local allocation strategies in Section VIII. We conclude the paper in Section IX.
Ii Related Work
Poisson Matching: Holroyd et al.  first studied translation-invariant matchings between two -dimensional Poisson processes with equal densities. Their primary focus was obtaining upper and lower bounds on matching distance for stable matchings. Abadi et al.  introduced UGS and derived bounds on the expected matching distance for stable matchings between two one-dimensional Poisson processes with different densities. In this paper, we propose another unidirectional allocation policy: “Move To Right” policy (MTR) and provide explicit expressions for the expected matching distance for both MTR and UGS when one set of points is distributed according to a renewal process.
Euclidean Bipartite Matching: The optimal requester-server assignment problem can be modeled as a minimum-weight matching on a weighted bipartite graph where weights on edges are given by the Euclidean distance between the corresponding vertices . Well-known polynomial time solutions exist for this problem, such as the modified Hungarian algorithm proposed by Agarwal et al.  with a running time of , where is the total number of requesters. In case of an equal number of requesters and servers, the optimal requester-server assignment on a real line is known . In this paper, we consider the case when there are fewer requesters than servers.
Iii Technical Preliminaries
Consider a set of requesters requesting tasks with equal computation requirements and a set of computation servers that can execute these requests. Assume that each server has capacity corresponding to maximum number of tasks that can be processed. Suppose requesters and servers are located in space . Formally, let and be the location functions for requesters and servers, respectively, such that a distance measure is well defined for all pairs . In this paper we examine the scenario where (say), i.e., the positive real line. We also assume that all servers have equal capacities i.e.
Iii-a Requester and server spatial distributions
Let represent successive requester locations and be the successive server locations. Let denote the inter-server distances and be the inter-requester distances. We consider
to be a renewal process with cumulative distribution function (c.d.f.) satisfying
We also assume is exponentially distributed with density i.e.
We denote and to be the mean and variance associated with the inter-server distance distribution .
In our paper, we consider various inter-server distance distributions, including exponential, deterministic, uniform, hyperexponential and Weibull.
Iii-B Allocation Policies
In this paper, one of our goal is to analyze the performance of various request allocation policies taking expected request distance as a performance metric. We define various allocation policies as follows.
Unidirectional Gale-Shapley (UGS):
In UGS, each requester simultaneously emits ray to their right. Once the ray hits an unallocated server , the emitter will be allocated to .
Move To Right (MTR):
In MTR, starting from left, each requester is allocated sequentially to the nearest available server to its right.
Nearest Neighbor (NN) :
In this matching, each requester greedily selects the nearest available server and we take that pair out, and continue.
Gale-Shapley (GS) :
In this matching, each requester selects the nearest server and each server selects its nearest requester. We only remove reciprocating pairs, and continue.
Optimal Matching: This matching provides the minimum average request distance among all feasible allocation policies.
Iv Unidirectional Allocation Policies
In this Section, we show the equivalence of UGS and MTR w.r.t the expected queue length distribution and the expected request distance.
Define and to be the number of requests that traverse point under UGS and in MTR respectively as shown in Figure 1. Let and be the corresponding distances between requester and its allocated server under both policies. We have the following theorem.
The distributions and and hence the expected request distance are the same for both UGS and MTR.
Due to the unidirectional nature of matching, both UGS and MTR have the same set of busy cycles. Busy cycles may be defined as groups of requests that are assigned to groups of servers with unallocated servers between groups. Consider any such busy cycle and let be a point on it. Let and denote the number of requesters and number of servers to the left of point in the busy cycle under UGS matching. Due to the unidirectional nature of matching, Similarly define and for MTR policy. Again due to unidirectional nature, As both matchings have the same set of busy cycles we have and Thus we get
Thus applying Little’s law we have
Note that Theorem 1 applies to any inter-server or inter-requester distance distribution. It also applies to the case where servers have capacities
V Unidirectional Poisson Matching
|Weibull||shape, : scale|
In this section, we characterize request distance statistics under unidirectional policies when both requesters and servers are distributed according to two independent Poisson processes. Let be the requester density and the server density. We first analyze MTR as follows.
We first consider the case when each server has unit capacity i.e.
V-A1 Server capacity:
When server capacity is one, the service network can be modeled as an M/M/1 queue. An M/M/1 queue consists of a single server with customer arrivals described by a Poisson process and customer service times by an exponential distribution. Thus the distance between two consecutive requesters in the service network can be thought of as inter-arrival time between customers in an M/M/1 queue. Similarly the distance between consecutive servers corresponds to a customer service time. In the service network, random variablecorresponds to the sojourn time of the customer in the M/M/1 queue and denotes the number of customers in the queue at time instant . If , then converges to a random variable Expo() and converges to a random variable Geo(). Thus we can evaluate request distance as
V-A2 Server capacity:
When server capacity is greater than one, the service network maps to a bulk service M/M/1 queue. A bulk service M/M/1 queue provides service to a group of customers. The server serves a bulk of at most customers whenever it becomes free. The service time for the group is exponentially distributed and customer arrivals are described by a Poisson process. Similar to the previous case, the distance between two consecutive requesters in the service network can be thought of as inter-arrival time between customers in the bulk service M/M/1 queue. However, the distance between two consecutive servers should be mapped to a bulk service time.
Having established an analogy between the service network and the bulk service M/M/1 queue, we now define the state space for the service network. Consider the definition of as the number of requests that traverse point under MTR. In steady state, converges to a random variable provided . Let denote where . The state space diagram for such a system is shown in Figure 2. Thus we have the following balance equations similar to that of a bulk service M/M/1 queue
By taking the -transform and following the procedure in 
, we obtain the steady state probability vectorBy applying Little’s formula, we obtain the following expression for the request distance
where is the only root in the interval of the following characteristic equation (with as the variable)
When both requesters and servers are Poisson distributed and servers have unit capacity then the request distance in UGS has the same distribution as the busy cycle in the corresponding Last-Come-First-Served Preemptive-Resume (LCFS-PR) queue having the density function 
where and is the modified Bessel function of the first kind. Thus the expected request distance is equivalent to the average busy cycle duration in LCFS-PR queue given by
Vi Unidirectional General Matching
In this Section, we derive expressions for the expected request distance when servers are distributed according to a renewal process. Assume each server has capacity Above spatial model can be mapped to a temporal M/G/1 queue where the first customer in a busy period receives different service from the others, . To illustrate this consider a busy cycle: as shown in Figure 3. can be thought of as the first customer in the busy period while sees the system busy when arrives. Let be the server placed on the immediate left of requester Clearly the service distance (spatial analogy of temporal service time) for requester is described by the random variable while for second requester by random variable When are distributed exponentially, both and are exponentially distributed with the same density due to the memoryless property of the exponential distribution. However, this is not true when is described by a renewal process. Denote and as the distribution and density functions for the random variable . Then the expected queue length and the expected sojourn time of a M/G/1 queue where the first customer in a busy period receives different service from the others is given by 
where and are the means associated with the service time distribution functions and respectively. Similarly and are the variances associated with and respectively. We assume in the spatial setting.
Vi-a Evaluation of the distribution function:
In this Section, we compute explicit expressions for the distribution function
In the spatial version, when a busy period starts, requests other than the first request gets a service distance . Let Expo() be the inter-request distance distribution. Using memoryless property of , the distribution function for the distance the first request in a busy period travels can be computed as
where is the distribution of the random variable (also known as difference distribution). can be expressed as
In this case, both and are exponentially distributed. Thus the difference distribution is given by
The c.d.f. for uniform distribution is
where is the uniform parameter. Thus we have
Taking and using Equation (12) we have
Taking and we have
We can substitute the values of in Equation (11) and obtain
Another interesting scenario is when servers are equally spaced at a distance from each other i.e. when The c.d.f. for deterministic distribution is
where is the deterministic parameter. A similar analysis as that of uniform distribution yields
where Thus we have
We have also considered other distributions, such as Hyper-exponential and Weibull distributions. The expressions for are presented in Table I. We can evaluate by setting
Vi-B Comparision with classical M/G/1 systems
In this section, we compare the results obtained for the unidirectional general matching to that of a classical M/G/1 system. The expected sojourn time of a classical M/G/1 queue is given by :
where Thus we have the following theorem.
When , the classical M/G/1 queue and the M/G/1 queue with exceptional service time have identical expected sojourn time given by the expression under finite mean and variance assumption.
When , the expected sojourn time in the M/G/1 queue with exceptional service time obtained from Equation (11) simplifies to
Similarly when , Equation (27) simplifies to ∎
Thus we expect the average request distance to exhibit similar behavior.
We validate the correctness of Theorem 2 through simulation as follows. We consider a deterministic inter-server distance distribution with parameter We compare the request distance obtained for MTR through simulation to that of in Equation (27) for . The comparison is presented in Figure 4 (Left). It is evident that when the average request distance in both the systems are exact. However, for moderate traffic, the average request distance in the classical version serves as an upper bound to the spatial version. We get similar results when inter-server distances are distributed according to a uniform distribution.
Note that if does not have a closed form expression, for example when Weibull, Equation (27) can be used to evaluate the expected request distance at heavy traffic.
Vi-C General request and server spatial distributions
Now, consider the case when the inter-requester distances have a general distribution with mean and variance We let with As , we can show that the behavior of MTR approaches that of the FCFS G/G/1 queue. It is known that the distribution of the waiting time in a G/G/1 queue will be approximately an exponentially distributed random variable and the mean sojourn time would then be given by
We expect the average request distance to exhibit similar behavior.
We study the behavior of spatial G/G/1 system when as follows. We consider deterministic inter-server distances with parameter We compare the average request distance obtained from simulation to that of in Equation (29) for . We assume the inter-requester distance distribution to be uniform. The comparison is presented in Figure 4 (Right). It is evident that as the average request distance in both spatial system and temporal G/G/1 system are exact. Thus we have the following conjecture.
At heavy traffic i.e. when , the classical G/G/1 queue and the G/G/1 queue with exceptional service time have identical expected sojourn time and is given by the expression .
Vii Bidirectional Allocation Policies
Both UGS and MTR minimize average request distance among all unidirectional policies. In this section we formulate the optimal request allocation policy for a bi-directional system with average request distance as the metric. Our objective is to find a function , such that
Let and denote number of requests and number of servers respectively. Let be locations of requests and be locations of servers. We first focus on the case when . We consider the following two scenarios.
When number of requesters and servers are equal, an optimal allocation strategy is given by the following theorem .
When an optimal assignment is obtained by the policy: i.e. allocating the request to the server and the average request distance is given by
Case 2: This is the case where there are fewer requesters than servers. In this case, the optimal assignment algorithm is presented in Algorithm 1. Before proceeding to the details of Algorithm 1, consider the following definition of group and a corresponding lemma.
Let be an assignment of requesters to servers. Under policy a group can be defined as a collection of consecutive allocated servers and requesters separated by an unallocated server on either end.
Let be a group with set of requesters and set of servers Let both and be sorted in increasing order of their positions. An optimal assignment policy for the group is obtained by allocating the request in to the server in
Clearly, by definition of group, Thus applying Theorem 3 yields an optimal policy. ∎
For example, consider the formation of groups and due to an optimal assignment as shown in Figure 5. The groups and are separated by an unallocated server Clearly, there can not be any matching edges between and as it would violate the optimality criterion. We exploit this particular structure of the optimal allocation and propose an optimal allocation policy as follows.
Let us now discuss Algorithm 1 in detail. Without loss of generality (W.l.o.g), let us denote as the optimal allocation for the set of requesters: Let denote the group containing requester as shown in Figure 5. Assume that Algorithm 1 has correctly produced optimal output at the iteration. Let be the last allocated server in i.e. the right most server in group We now wish to find an optimal allocation policy for the set of requesters: Let be the nearest unallocated server to requester s.t. If then we allocate server to requester This might result in creation of a new group or extension of the existing group Let be the nearest unallocated server immediately left of group The case when we shift the allocation of each requester in to one server left of their current allocations while allocating the first requester in to forming a new policy We then compare the costs associated to that of If the policy has lower cost, we repeat the process of shifting left until either is more expensive to perform a shift or there are no more unallocated servers to the left of group .
Vii-a Proof of correctness
It is trivial to check that the stopping criteria in Lines 4 and 11 in Algorithm 1 ensures optimality. Hence we shift our focus to the criterion on Line 16. Consider the definitions of and introduced earlier. Let and be the set of requesters and the set of servers for group . By Lemma 1 an optimal allocation for requesters and servers corresponds to allocating them sequentially in increasing order of their locations. The ShiftLeft operation in Line 9 ensures this order. Thus the value of cost in Line 10 is optimal w.r.t all other policies given is assigned to Now consider the stopping criterion on Line 16. Clearly if then Thus we have Hence traversing further to the left of server will not yield a better solution.
Vii-B Time complexity
The modules LastAllocated, NearestUnallocatedToRight and FindNearest can be executed in time by simple book keeping and preprocessing such as merging the sorted arrays and The comparison between costs cost and cost in Line 10 can be implemented through incurring a time complexity of where is the group of maximum cardinality in the optimal solution. The ShiftLeft operation in Line 9 incurs a time complexity of Thus the time complexity for module OptCurr is and the total complexity of Algorithm 1 is In the worst case, . Thus the total worst case time complexity of Algorithm 1 is . However, in the next Section, we show that the average group sizes in optimal solutions are very small and the expected running time of Algorithm 1 is conjectured to be , significantly less than what is described above.
Viii Performance Comparison
In this section, we compare the performance of various greedy allocation strategies along with the unidirectional policies to the optimal strategy.
Viii-a Experimental Setup
In our experiments, we consider requesters to be poisson distributed with density We consider various inter-server distance distributions with an expected value of In particular, (i) for exponential distributions, the density is set to ; (ii) for deterministic distributions, we assign parameter We consider a collection of requesters and servers, i.e. Then, we assign requesters according to the UGS. Let be the set of requesters allocated under UGS matching. Clearly We then run optimal and other greedy policies on the set and For each of the experiments, the expected request distance for the corresponding policy is averaged over trials.
Viii-B Comparison of different allocation policies
We first consider the case when both requesters and servers are distributed according to Poisson processes. From Figure 6 (Left), we observe that due to its directional nature UGS or MTR has a larger expected request distance as compared to other policies. At low loads i.e. when , the bidirectional greedy allocation policies perform similar to the optimal policy. But as the Nearest Neighbor policy perform worse and approach to that of UGS or MTR. The Gale-Shapley greedy allocation works reasonably well in both cases. Next we consider the case when the inter-server distance distribution is deterministic. We observe similar trends as that of the Poisson case as shown in Figure 6 (Right). However, under equal load, all the policies have smaller expected request distance as compared to their Poisson counterpart.
Above discussion advocates for placing equidistant servers in a bidirectional system with Poisson distributed requesters to minimize expected request distance.
Viii-C Distribution of group size
M/M/1 arrivals: When servers and requesters are located according to Poisson processes with densities and with , there is a stationary regime where groups of requests are assigned to groups of servers with unallocated servers between groups. These would correspond to “busy periods” in temporal queuing processes. Note that the expected number of consecutively allocated servers in the unidirectional policy MTR is where . We conjecture this to be the case for optimal assignment as well. First we plot the average number of program variable comparisons inside module OptCurr in Algorithm 1 as shown in Figure 7 (left). Clearly, the average number of comparisons are small and do not depend on . We also plot the probability distribution of group sizes for an optimal policy with requester density and server density as shown in Figure 7 (Right). It is evident that the distribution is concentrated around while the expression
In this paper, we introduced a queuing theoretic model for analyzing the behavior of unidirectional policies to allocate tasks to servers on the real line. We show the equivalence of UGS and MTR w.r.t the expected request distance and present results associated with the case when servers are Poisson distributed and with a general inter-server distance distribution. We also proposed an algorithm to obtain an optimal allocation policy in a bi-directional system and compared the performance of various greedy allocation strategies along with the unidirectional policies to that of optimal policy. Going further, we aim to extend our results in two ways. First we would like to extend the analysis for unidirectional policies to a two-dimensional geographic region. Second we would also consider analyzing the case when servers have different capacities.
-  H. K. Abadi and B. Prabhakar. Stable Matchings in Metric Spaces: Modeling Real-World Preferences using Proximity. arXiv:1710.05262, 2017.
-  P. Agarwal, A. Efrat, and M. Sharir. Vertical Decomposition of Shallow Levels in 3-Dimensional Arrangements and Its Applications. SOCG, 1995.
-  R. Ahuja, T. Magnanti, and J. Orlin. Network Flows: Theory, Algorithms, and Applications. Prentice-Hall, Inc, 1993.
-  A. Asadi, Q. Wang, and V. Mancuso. A Survey on Device-to-device Communication in Cellular Networks. In IEEE Commun. Surv. Tut, 2013.
-  L. Atzori, A. Iera, and G. Morabito. The Internet of Things: A Survey. Computer Networks, 54(15):2787–2805, 2010.
-  J. Bukac. Matching On a Line. arXiv:1805.00214, 2018.
-  D. Gale and L. Shapley. College Admissions and Stability of Marriage. Amer. Math. Monthly 69, pages 9–15, 1962.
-  D. Gross and C. Harris. Fundamentals of Queueing Theory. Wiley Series in Probability and Statistics, 1998.
-  A. E. Holroyd, R. Pemantle, R. Peres, and O. Schramm. Poisson Matching. Annales de l IHP Probabilites et Statistiques, 45:266–287, 2009.
-  F. Kingman. The Effect of Queue Discipline on Waiting Time Variance. Math. Proc. Cambridge Phil. Soc., 58:163–164, 1962.
-  L. Kleinrock. Queueing Systems. John Wiley and Sons, 1976.
-  M. Mezard and G. Parisi. The Euclidean Matching Problem. J. Phys. France, 49:2019–2025, 1988.
-  J. Orlin. A Polynomial Time Primal Network Simplex Algorithm for Minimum Cost Flows. Mathematical Programming, 78:109–129, 1997.
-  E. Stuart. Matching Methods for Causal Inference: a Review and a Look Forward. Stat. Sci., 25:1–21, 2010.
-  P. Welch. On a Generalized m/g/1 Queuing Process in Which The First Customer of Each Busy Period Receives Exceptional Service. Operations Research, 12:736–752, 1964.