distribute traffic across multiple strongswan ikev2 connections

i would like a setup where a strongswan client connects to multiple endpoints with rightsubnet=0.0.0.0/0 that machine is then used as the default gateway for a few machines.

however i do not understand how strongswan sets up the routing, as iproute2 doesnt see any interfaces.

ideally this scenario would also be dynamic in that new uplinks can be torn up/down gracefully

How to distribute code reviews workload in a small team?

I have a small team where I’m largely the only person who reviews what goes into production and makes sure that the code introduced doesn’t contradict business logic, no bugs etc.. I know a lot of this can be improved with tests and we often use them, however I see tests at most complementing the human code review (what was tested, how it was tested will for instance always need a review of the tests and the code under test).

However, this all means I’ve become a bottleneck and a big part of my job has become about reviewing code which is a bit soul-sucking after a while. I’m sure there’s many ways to spread the load (mainly I want to include everyone else in the review processes) but I am not sure how to start because I am more senior and have more experience with our system, and I’m not sure what I should be aiming for.

Would be happy to hear suggestions to have a better idea of what I should be aiming for, and what the best way to get there is.

Algorithm to distribute items “evenly”

I’m searching for an algorithm to distribute values from a list so that the resulting list is as “balanced” or “evenly distributed” as possible (in quotes because I’m not sure these are the best ways to describe it… later I’ll provide a way to measure if a result is better than other).

So, for the list:

[1, 1, 2, 2, 3, 3] 

One of the best results, after re-distributing the values, is:

[1, 2, 3, 1, 2, 3] 

There may be other results as good as this one, and of course this gets more complicated with a less uniform set of values.

This is how to measure if a result is better than other:

  1. Count the distances between each item and the next item with the same value.

  2. Calculate the standard deviation for that set of distances. A lower dispersion means a better result.

Observations:

  • When calculating a distance and the end of the list is reached without finding an item with the same value, we go back to the beginning of the list. So, at most, the same item will be found and the distance for that item will be the length of the list. This means that the list is cyclic;
  • A typical list has ~50 items with ~15 different values in varied quantities.

So:

  • For the result [1, 2, 3, 1, 2, 3], the distances are [3, 3, 3, 3, 3, 3], and the standard deviation is 0;
  • For the result [1, 1, 2, 2, 3, 3], the distances are [1, 5, 1, 5, 1, 5], and the standard deviation is 2;
  • Which makes the first result better than the second (lower deviation is better).

Given these definitions, I ask for a clue of which algorithms or strategies should I search for.

Distribute jobs evenly among a set of servers

I have the need to distribute a set of long running jobs across a cluster of containers in ECS. These jobs essentially would need to open a socket connection with a remote server and begin streaming data for import into a database.

For each customer, there may be any number of socket connections required to consume different data feeds. Creating a new ECS service for each customer is not practical as this would also require new ECS task definitions with slightly different configurations, which ultimately would result in having 1000s of services/task definitions. This approach would quickly become a maintenance and monitoring nightmare, so I am looking for a simpler solution.

The list of “feeds” is relatively static and is stored in a document database. Feeds are only added as new customers sign up. My initial thought is to have a fixed number of containers responsible for fetching the feed configurations from the database. Each container would attempt to acquire a lease for the feed, and if acquired, start the feed and let it run until the container is killed or the connection is interrupted. Each container would have to periodically check for new feeds that are available in the pool. They would also have to extend the lease while the feed is running so the same feed isn’t pulled by another container. There could be a race condition here where the lease expires before it is extended, so I’d have to be careful to always extend the lease.

This solution would work, but there are some obvious sticking points. If each container starts at relatively the same time, there needs to be a way to control how many jobs each container is allowed to start at one time so that you don’t have 1 or 2 containers starting all of the jobs at once. One approach would be to pull one job every couple seconds until the pool is empty and all feeds are leased. This would lead to potentially uneven job distribution, and the ramp up time might take a while until all jobs are pulled from the pool and leased. I could also have the containers fetch a feed and start it, then go grab another one. Some containers may start their feeds faster and go fetch another job before another container could finish starting its feed, thereby leading to container hot spots.

Another approach could be using something like consistent hashing. If each container can know the ID of itself and the other containers, it can hash the feed configuration ID and figure out which container it belongs on. This would distribute the jobs more evenly, but I would also have to deal with checking periodically for new feeds, for example, if a container were killed and the feeds leases expired.

I have also thought that actor programming like with Akka might be exactly for this problem, but that does not come without significant complexity in implementation.

I am open to any and all suggestions or any other holes you can poke into my existing proposals!

How to proportionally distribute values in a new rating system?

I’m very new to this so please bear with me. So I want to take a list of websites and create an algorithm based on the domain ranking and translate it to a rating system of 1-5. A website with a ranking of 2193 will be closer to 5 then say a website with a ranking of 100,832. I have a generic scaling algo that looks like this:

4 * (((max_rank – actual_rank) – min_rank) / (max_rank – min_rank)) + 1

The problem with this is that the scaling isn’t proportional to its domain ranking. A website with a rank of 675,090 has a new rating of 4.798 and one with a rank of 1,814,100 has a new rating of 4.458. The difference between the 1-5 scaling doesn’t appear to go along the lines with the original ranking. I’m not well versed in math so I’m not sure if I explained this right.

App store require Documents for authorized to distribute the content

i publish my application on app store but it’s not accepted in several time and the reviewer request for the document for authorized to distribute the content but i don’t know how to document ?

the app store reviewer Answer :

Thank you for your message. Please respond with documentation attached, using the upload feature, evidencing that Jenyar has been authorized to distribute the content owned by the artists. Once Legal has reviewed your documentation and confirms its validity, we will proceed with your application review.

please if anybody know about this guide me Thanks

Distribute repeated values into bins as evenly as possible

Preface

I’ve asked a very similar question already on stack overflow in a different wording and gotten a working answer under the assumption that there is no way to go through all possibilities (np-hard).

After doing further research (because this is my bottleneck atm), I stumbled upon this similar question, but again, there’s the assumption of the problem beeing np-hard and it’s not exactly what I’m looking for. However, it seems the question is a better fit on this site, than SO (correct me if I’m wrong).

I’m pretty sure this can be solved “brute force” (aka optimal) with the correct algorithm in small time for the given constraints. More to that later.

Problem

I have a small set of repeating values e.g.

values = 10 x [18] (ten times the value 18); 5 x [30], 6 x [55] 

of which I need to distribute as many as possible evenly across a fixed number of bins with a maximum difference between the bins (maximum difference between the sum of elements in the bins, see below).

Constraints:

The reason I think this can be brute forced are my constraints. I will never have a great number of bins (at the moment the maximum is 3, let’s assume it might be 4 or 5 though). The maximum difference between the bins is atm fixed at 2, we can assume it stays there if that helps because I can set this arbitrarily if needed.

Example

For a small example, lets set values = [[18,18,18,18,18],[30,30,30]], number_of_bins = 2 and max_difference_between_bins = 2.

The algorithm to distribute them would be something along the lines

for remainder in range(0,8) #try distributing all packages first,   # then one less, then two less, etc.     generate possible distributions for values in bins     add the distributions to check differences, if any difference        # is below the threshhold of max max_difference_between_bins, break 

Trying it out:

Remainder = 0

Distribute 5 times 18 into two bins:

(0,90),(18,72),(36,36),(72,18),(90,0) 

Distribute 3 times 30 into two bins:

(0,90),(30,60),(60,30),(90,0) 

See that the example is bad because it works out in the first run, anyways, adding them yields:

(0,90) -> (0,180),(30,150),(60,120),(90,90) (18,72)-> (18,162),(48,132),(78,102)(108,72) (36,36)-> (36,126),(66,96),(96,66)(126,36) (72,18)-> (72,108),(102,78),(132,48),(162,18) (90,0) -> (90,90),(120,60),(150,30),(180,0) 

As you can see, half of them are obsolete because they are duplicates.

If there hadn’t been a solution (90,90) this would then continue in the next run with trying the same for values = [[18,18,18,18],[30,30,30]] and values = [[18,18,18,18,18],[30,30]] and remainder = [18] or remainder = [30].

Runtime

So for a really big example of say 70 values with 5 different sizes distributed across 3 bins, the possible solutions should be for the first run:

Say 50 values of the same size are distributed across 3 bins, then we get 50+3-1 over 3 = 1326 possibilites or 316251 for 5 bins (right?) (supposing the bins are differentiable, which they don’t need to be, but then we would have to upscale later for the combination with the other values).

Distributing the other 20 with say 8, 5, 4, 3 values each thats 45, 21, 15, 10 values. Multiplicated, that’s 190 million possibilities. However, most of those combinations can’t possibly be a good solution. Some depth search or divide and conquer should be able to break them down.

Of course, those are then multiplied by 5 for the first run with a remainder of 1, by 120 for a run with a remainder of 2, etc. But those solutions can also be generated from the old solutions and again, it should be possible to go through only a fraction of them.

Question

Is basically, how do I get a solution for this in small time? Pseudocode or even python would be great, but not necessary, I can figure the coding out myself.

We can make many assumptions for the number of different values and maximum number of values you want, so if you think the part about reducing it from 190 million times whatever solutions is too big, I’m fine with going down to, for example, maximum 3 bins, maximum 3 different values occuring a maximum of, say, 20 times together (so not 20 times this, 20 times that, but rather 10 times this, 5 times that, 5 times the other).