0

We're currently trying to break down our monolith in microservices and I have currently a problem with a use case.

We have the following use cases/requests from the client

  • The user can get bookdetails
  • The user can manage private booknotes
  • The user can manage private favoritelists of books

now we created a complex access process. there are a few filter which declare if you have a visibility on those books. They can change always as example, the customer buys a new subscription and have instant access to those books. Every request with a book, has to use this access logic. in most use case it's a simple access service, which returns if you have access to a book or not. So we can theoretically create a "access microservice".

But in the favoritelist we have a paging on the sql request. In this sql request are all the access filter included, which is indeed really painfully. My problem now is, how can I create a paging favoritelist, where another microservice defines a filter.

Currently my best solution is to get all favorites of a customer, filter all those favorites with the access service in cache and then make a paging in cache. But as always, there are customer with about 5'000 books in their favoritelist.

It sounds odd, that you can have a book in your favoritelist, which you can't see. This is because your subscription can expire and we don't want to remove this books from your favoritelist, if you buy a new subscription. Also there are different devices which have a smaller amount of books available. Which means on the website you can see the book, but on the smartphone app probably not. (there are different apps for different use cases)

How can I split those use case in good microservices? I'm currently reading alot about microservice and they say the microservice shouldn't call each other. How should the favoritelist service know which books a customer have access on the current device? the access service has a really large cohesion with almost every service, how can I remove this cohesion? I can't cache the access of a customer on the favoritelist service (we have about 1mio books and customers.).

enter image description here

wydy
  • 173
  • 14
  • It is hard to give an advice with the provided input. But at least I can help you to improve your question. When you talk about "product" do you mean a "book"? how do you define the access control? Based on each and every product/book or based some other concept like subscription type, book type, etc. Can you for example create an entity to pass to your book service to do the actual filtering based on the defined rules? Like create a proper list of authorized list of book types and apply this filter to the actual book list? And who manages those authorization list? – cool Aug 04 '20 at 13:40
  • you have a list of roles. A customer can have 0-n roles, which are the different subscriptions. there is a mapping table which says which role has read access to which book. Also there is a list of devices. there is a mapping table which says which device has read access to which book. There is also an unlock list, where you can unlock a book for a specific customer (giftcard). A mapping between customer and books. there are marketing people who manage the access on a user interface and change the list frequently. hope that helps. the access management is getting more and more complex – wydy Aug 04 '20 at 14:01
  • I will create a database/table diagram to visualize it a bit better. But that takes a few minutes – wydy Aug 04 '20 at 14:10
  • A product question: what if you don't filter the favorites but fetch the whole list and show the inaccessible one in a different way than the accessible one and not let the customer to get to the content of the inaccessible ones. This is how it works for apple movie for example. – cool Aug 04 '20 at 14:14
  • Otherwise filtering the list of items on access service sounds ok to me. If you are filtering based on just ids 5k is not a big number and you can cache this id list. – cool Aug 04 '20 at 14:17
  • It's not my or the idea of the PO to filter products in the favoritelist. It's an explicit wish from the customer. We already spoke a lot about it. My suggestion was to use different favoritelist for every app. Isn't it a bit much businesslogic to filter 5k items just to show 20 to the customer. I could iterate through the items and ask for the next, till I have my page full. But that will be at least 20 requests, which is again slow. I added a small diagram. Hope that helps. I hoped there would be a technic/pattern which helps me to split such cohesion simpler, but I didn't find anything – wydy Aug 04 '20 at 14:52
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/219242/discussion-between-cool-and-wydy). – cool Aug 05 '20 at 07:17

0 Answers0