Hi. I just started to look at event sourcing a few days ago, and decided to make a small project using it to test out the different technologies. After watching a good few talks on the subject, and reading some of the information available, I think the overall design of the system I’m planning to make is starting to take somewhat of a shape in my head, but I thought I’d ask about it here since I’m new to all of this and it might be a completely wrong approach.
The system I’m planning can be considered to be a blog-like system consisting of posts posted in categories and a user database. Now what I’ve started thinking about is the fact that you can have different read “systems” for your data, which is somewhat intriguing I think, so I was thinking of having a service that dealt with login and another one that dealt with the “blog” posts.
Here are my thoughts so far:
2 (or more) write services. One for the registration/manipulation of users, and another one for categories and posts. These do business logic, and optimistic validation against the read store (like checking if email is already in use) and then simply write to the event store.
1 login service. This subscribes to the event store and builds up an in-memory user database. Considering there shouldn’t be too many users, in memory should be fine. This service implements SSO, as well as some simple APIs for the write service to check if an email is in use etc.
1 static content generator. I’m thinking similar to how GitHub pages work, I can just subscribe to posts in the event store, and generate static content for them, then put it behind a simple nginx server or similar.
So my main question is this: Does this seem like a reasonable approach? At least to get started? Obviously this system would not have much traffic, cause it’s just something I’m building as a hobby to test out technologies, but I’m trying to lean how one can build something that can be scaled, so for instance I really liked the idea of doing static page generation that could be distributed to as many “simple” nodes as I would want to support huge amounts of traffic that would provide eventual consistency (cause I don’t really care if it takes a few minutes or more before the posts are visible to the world). Also, this could ensure that even if my “blog site” is being DDOSed, I could still have the “admin site”, where one would go to write posts be completely functional, cause they are two different systems.
I also have a question with regards to eventual consistency, which is something I’ve never worked with before. One of the talks I saw had a great example of two users trying to register at “the same time” with the same email address. Both events were allowed into the event store, then in the handler when the second UserRegistered event was being handled, it saw that it was a duplicate email address, and created a new event to describe the error, while sending out a mail to the user explaining that something went wrong. Now, this is all fine, and the functionality should be easy to create, but my question is this: If I later down the line create a second (or restart) my event handler, how am I supposed to prevent it from sending the mail again? Do I keep track of “up to which event” has been handled somewhere? What’s a good way to deal with this situation?
Thanks. Alxandr.