This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.
Message originally sent by slack user U7213XMGS3H
I’ve been thinking a lot about how to break up monoliths and I started wondering if Graph Theory could help. I’m motivated by the fact that large rails monoliths are very entangled and it can be tricky to decide where the boundaries should go. Not knowing a great deal about Graph Theory, I gave myself a weekend to try to determine model clusters as a proxy for packs at my company. The results were very encouraging for a weekend, so I thought I’d share.
My steps were to
- Make a rake task that created a JSON file of all of our AR models and their relationships
- Throw that into Neo4j
- Use the Louvain community detection algo (because I didn’t want to specify in advance how many clusters to identify, I had a directed graph, I didn’t have weights in my graph, and I knew a fair amount about the domain. I think there’s lots of room to play here and figure out some weights or try different approaches.)
- Play with the output…
The community sizes weren’t perfect
[247,75,60,42,34,31,30,27,20,9,9,8,5,4,3,3,3,3,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
247 models is too many for one pack, as is 75 or 60. But the medium sized ones were really interesting. They looked like they actually represented reasonable boundaries.
Has anyone tried anything like this before? Any ideas for me? I feel like this would be an incredible blog post if my clusters were ~30% better