CMS in Crystal, how hard it may be?

Greetings community!

My question is - how hard it may be to build a robust yet salable CMS in Crystal?

I’m using Prestashop eCommerce CMS, based on PHP and SQL for some time. But things got more and more complicated then custom business logic was needed to be implemented. So now I want a more simple solution that wont be hard to modify for different use cases.

What I have in my mind is:

  • Keep most things in memory as an object - products data, logged in customers data and so on, and write to a persistent media only on effective changes. For a 2k products shop it should not be a lot of memory.
    But I’m thinking to expand this idea to Html content also. To be able to easily create and edit objects, that would be something like web components, a tool may be needed. Something like a web page builder, maybe even a drag and drop one.
    That object based view should interact with business logic with some kind of interface (like Uncle Bob Martin’s interactor).
    I do understand that making all that possible is a lot of work. But I believe it may be started with some simple components and if the architecture is good it will scale well later.

  • For a friction-less interaction of the model that was I describing with a persistent media I’m looking at NoSql solutions. Leveldb or Roksdb may be the way. But how it may be to have a complex query on that thing? On the other hand Redis may be perfect but I don’t want to load in memory old or seldom used data. And I haven’t seen NoSql be spported by most known Crystal frameworks. In fact I’m seek and tired of a typical eCommerce over complicated db structure and rigidity. I want something that is easy to modify according to needs.

  • Reliability. Since I’m just learning Crystal it’s a concern for me. Maybe Elixir with “Let it crash” is a better choice for me? But I may need much more time to understand it since I’m coming from PHP. I choose Crystal for it’s syntax, for me this mean - easier to understand and maintain the code, and for how easy it can be deployed, compared to Elixir. But I’m concerned about if there is a bug in function - would it crash the whole server?

What you think about this? Any comment is welcome.

1 Like

About reliability - unhandled exception will crash only one fiber (they are created for each connection), so that’s not a problem.
But if you have shared state (products data, logged users etc) and something bad will be written to it due to a bug (i don’t know, customer with links to deleted products?) all connections that try to use it would crash in a same way.


So fibers will save me from a total server crash (that I was afraid about in a compiled language) - that is great. I’ll read more about them.
To reduce bugs and simplify the internal logic I was thinking about keeping everything as objects. I understand that I have to think carefully how objects will interact .
Thanx for your comment.

1 Like

Hey! Are you still interested in the project?

I prefer to Redis.

I had too much of issues with Redis when you have a lot of data that needs to be updated quite often.
The issue with Redis that it is single threaded, while Aerospike is multithreaded and has much more features and better performance (automatic sharding and data rebalancing between the nodes).
On bigger instances Aerospike can handle more then 1 million requests per second.

Redis next version (going into stable in the next months) is going to be multithreaded :)

You can run any number of redis replica to get more speed. You can get 230K rps with modern CPU core with 1 thread with redis.

Twitter use Redis, just saying.

I tried to use sharding in Redis. Due to the extensive usage of LUA scripts and data interdependency it was not possible to use Redis router and sharding.

Still Aerospike is ahead and much more reliable at this moment for my needs. I will pay attention to Redis to see if they were able to improve their persistency,