Are recursive microservices a good idea?

Viewed 20

This project is still in the planning stage and I'm very new to micro services.

We have a client who uses a web UI that's now pretty outdated. Most of the API does lend itself you a micro service approach, but they do have one "heavy load" process; "Proportionment".

Here is an analogy of how this process works.

Investment A has five equal investors (20% each).

Three of those investors manage their own dividend proportionment so get allocated their 20%, job done.

The other 2 are groups of investors who rely on the software to work out their distribution.

Group A4 consists of 4 individuals so each get allocated 25% of the 20% (5% of total), job done.

Group A5 has again a mix of individuals and groups... etc. ad infinitum

This report would be performed at Month-End for some investments or as Year End for others. That can lead to a lot of work for the system to do.

I guess you will want to see a more code-oriented example so here:

const Group = [
  {"InvestorId": 1, "Percent":0.2},
  {"InvestorId": 2, "Percent":0.2},
  {"InvestorId": 3, "Percent":0.2},
  {"InvestorId": 4, "Percent":0.2,"Group":[
    {"InvestorId": 6, "Percent":0.25},
    {"InvestorId": 7, "Percent":0.25},
    {"InvestorId": 8, "Percent":0.25},
    {"InvestorId": 9, "Percent":0.25}]},
  {"InvestorId": 5, "Percent":0.2,"Group":[
    {"InvestorId": 10, "Percent":0.25},
    {"InvestorId": 11, "Percent":0.25},
    {"InvestorId": 12, "Percent":0.25},
    {"InvestorId": 13, "Percent":0.25,"Group":[   
      {"InvestorId": 14, "Percent":0.1},
      {"InvestorId": 15, "Percent":0.2},
      {"InvestorId": 16, "Percent":0.3},
      {"InvestorId": 17, "Percent":0.3},
      {"InvestorId": 18, "Percent":0.1}
    ]}]}
]

const SFC = props => {
  <div>{props.label}</div>
}

class Proportion extends React.Component {
  render() {
    const {group,total} = this.props
    return (
      <div>
        <ol>
        {group.map(item => (
          <li>
            <label>ID: {item.InvestorId}</label>
            {item.Group 
            ?<Proportion group={item.Group} total={total * item.Percent} />
            :<span>£{total * item.Percent}</span>
            }
          </li>
        ))}
        </ol>
      </div>
    )
  }
}

ReactDOM.render(<Proportion group={Group} total={1000000} />, document.body)
label {
  width:200px;
  display:block
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

So here's the question: Should I...

  1. Recurse this process by calling the microservice that proportions per group
  2. Have a single service performing the whole thing on the cluster
  3. Have a single serving performing the whole thing on premises

Thanks ^_^

0 Answers
Related