What is scalable? Simple CRUD Webapp vs Webapp talking to REST service

I think the name says it clearly. I am not a guru of scalability. I'm on the verge of creating a web application that needs to be scaled for large datasets, and possibly for many (usually don't exaggerate, say, thousands) of concurrent users.

MongoDB is a data warehouse, and I'm torn between writing a simple Play! webapp talking to MongoDB versus Play! an application related to a REST service application (in Scala), which makes heavy lifting all the business logic and perseverance.

Part of me thinks that having business logic wrapped up as a service is future proof and allows you to deploy only webapp to multiple nodes (scaling). I came from Java EE stack and Play! is a rebel in java networks. This approach convinces me that I can move away from Play! if necessary.

Part of me also thinks that Play! app + Scala application-application is an additional complexity and cannot be fruitful in the long run.

Any suggestions are welcome.

NOTE. I am new to Scala, MongoDB and Play !. Forgive me if my question is stupid.

+6
source share
4 answers

Scalability is an engineering skill. This means that you have many parameters and apply your experience to the specific values ​​of these parameters in order to arrive at a solution. Therefore, the general advice, without any specific data about your problem, is complicated.

Having said this, from experience, is a general tip:

  • Keep the application as simple and simple as possible. This allows you to keep your options open. In your case, start with the simple Play app. Focus on clean code so you can easily re-process what you have in a different architectural model (with clean code that is simpler than you think :-))
  • Measure, do not guess where the bottlenecks are. It is simple enough to fill the server with requests. Use profiling, memory dumps, anything to pinpoint a bottleneck in scalability.

Only when the working application is in your hand (with which you can start from the earliest time) and data on where your bottlenecks are to scale, can you make decisions about what needs to be separated by (horizontally scaleable) services.

From the very beginning, services look nice and scalable, but they often help you in an early mess - the services must communicate with each other, so you start typing messages, etc. Keep it simple, measure, optimize.

+5
source

The question does not seem silly. For me, encapsulating your access to data behind the rest of the layer does not directly improve the scalability of the application (of course, there is a server that can perform HTTP caching and process request queues, etc., but from your description, your application looks quite small). You can achieve similar scalability without the Rest layer. But by saying this, the level of service can have an indirect effect.

At first it makes your application cleaner. (UI Talking to db is dirty.). This helps make the application convenient. (Multi folds). The level of relaxation can provide you with the average level that you may need in your application. Also, a properly designed level of rest should be linked to resources. In my experience, resource-driven architecture is a good medium between ease of implementation and highly scalable design.

Therefore, I strongly recommend that you use the service level ("Rest is the way to go :)), but scalability alone cannot justify the solution.

+2
source

Enabling the service between the user interface and the data source encapsulates the data source, so the user interface does not need to know the details of how the data is stored. It also prevents the user interface from accessing the data source directly. This allows the service to authenticate, authorize, verify, link, and execute business process logic as needed.

The disadvantage is a slight decrease in speed for the application.

I would say that adding a service has a low cost and great growth potential. I voted for it.

+1
source

The answer, as usual, is. It depends. If there is some kind of heavy lift and some kind of business logic: Yup, it’s best to put it in your own layer, and if you add a RESTful interface to it, you can serve it up to any front-end technology that you want .

Nowadays, people often do not worry about having a separate layer of web applications, but serve data through AJAX directly to the client.

You might consider adding a layer if you need to either support many user session states or be able to cache data at presentation level. There are several more reasons why you need a presentation level, for example, making various presentations for different devices / clients.

Don't just add layers for complexity, though.

I would add that you should try to use the HATEOAS principle. This will greatly facilitate the situation when scaling the solution.

+1
source

Source: https://habr.com/ru/post/892532/


All Articles