T
T
TheMrViper2015-01-10 03:49:01
Python
TheMrViper, 2015-01-10 03:49:01

What language to choose for api server?

Good day.
I ask for your help and advice, I started the project, and I am doing a web part for it.
There are servers on which everything will stand.
I can’t choose for myself the language/languages ​​in which to write the site and the api service (
You need to write two parts:
A site for users.
Api server that will respond to requests from the site, they will be available only to the site itself, users will not even know about them
Requirements: The
site will be viewed by users, and do all sorts of things, it should be as fast as possible.
Api will perform resource-intensive tasks: calculations, writing from the database to a file and vice versa, and other functions that the site cannot withstand. Api must be multi-threaded, there can be no talk of any asynchrony, it must be able to process a lot at once.
Writing everything in one place is not suitable. many sites will access the api server.
From the beginning, I started writing like this:
A site in PHP - which was accessed by
Api users in C # - which received requests from the site and responded to it.
But to be honest, I didn’t like this bunch at the very beginning, I don’t know why.
The site and the api server can communicate using any protocol, as long as it is convenient to implement it in the selected languages. In the case of what I wrote, they simply communicated, the API accepted and returned JSON.
Here is an approximate diagram of how everything should be arranged:
c19b74fe2c6e419296cbe3876518568a.png
The database of the site (the one on top) can be, in principle, any, as long as it is fast.
Though it is more preferable MySQL for very much got used to it.
Thanks and I look forward to your help.

Answer the question

In order to leave comments, you need to log in

10 answer(s)
I
index0h, 2015-01-10
@TheMrViper

1. For serious computing, you may need a whole cluster + ***MQ for queuing.
2. For long-term / large-scale calculations - php is not quite a cake. PHP Hypertext Processor, but for some reason a lot of people forget about this fact.
3. C++ is worth using if you can justify why)).
4. In principle, I recommend looking towards Golang.

V
Viktor Vsk, 2015-01-10
@viktorvsk

The site will be viewed by users, and do all sorts of different things. it should be as fast as possible.

premature optimization. The site for the user will be fast if all the nuances of the frontend are taken into account (caching, minification, sprites, different subdomains for assets ...), and the server has caching and, where necessary, queues configured correctly.
Separation into different applications is just part of the architecture and does not have to meet performance requirements.
The API does not do the job. And calculations and writing from the database to the file are not resource-intensive operations in the general case. And the site usually does not produce them either. In this context, the site is more of a front-end. And the calculations will be done on the server.
I didn't understand it at all. Multithreading depends on the type and settings of the web server (for example, the one on nginx). What did not please the asynchrony - is also not clear. And how it depends on the ability to process a lot and at once is just as unclear. In a very simplistic way, you can say that with the help of asynchrony, you can give the user the impression that the site responds instantly (works very quickly).
Perhaps this is all because it is 3 (4) in the morning and you have digested a very large amount of information. Then try to be specific.
Essentially if:
1. It doesn't matter which language to choose. The one you know best. Anything can be implemented in any language. Most of the "performance" is achieved not due to the speed of the standard library of the language, but due to caching, optimizing sql queries, setting up a web server and database, and using queues.
2. Apparently, the question is important for you: "Is it worth separating the server API and the application client into different applications, languages, instances?". It will not be possible to answer here immediately, because everything depends on the task. Depending on how you will use your instances. What calculations will be carried out, etc. - More specifics on the subject area.

V
vsuhachev, 2015-01-10
@vsuhachev

Basically you are creating 2 separate applications. Both applications can be written in the same language, if you like / know PHP - write everything in it. Use queues to perform time-consuming resource-intensive tasks. In any case, using different technology stacks (PHP and .NET) without good reason is not rational at the same time, it is better to work in the same stack.

S
sakuradaj, 2015-01-10
@sakuradaj

The site will be viewed by users, and do all sorts of different things. it should be as fast as possible.

How fast exactly? It is not very clear what these requirements are. It is possible that you are engaged in premature optimization.
From the beginning, I started writing like this:
A site in PHP - which was accessed by
Api users in C # - which received requests from the site and responded to it.
But to be honest, I didn’t like this bunch at the very beginning, I don’t know why.
I still don’t see what caused the need to use two different languages ​​​​for your application, it seems to me that this is redundant, this causes more headaches and confusion.
In general, I would write in that language / framework with which I have more experience and php, python, ruby, etc are pretty equivalent here ... and maybe some other new ones like Go or node.js, that's not the point.
If you want speed, then make parts of your application horizontally scalable (that is, for example, you can run 10 copies of your application on different servers and its architecture will be such that everything will work fine).
Plus, as they wrote here, think no longer about the language, but about optimizing the database and interacting with it, caching in the right places, usually there are the bottlenecks.

A
Alexander Aksentiev, 2015-01-10
@Sanasol

What you know how to write on. And how fast it will work depends on how well you do it.
But if you need to calculate something very serious, then it's probably better to choose python (django) / ruby ​​(onrails)
Perhaps these are quite fast options.
Demon in C (any) is also a fast option with the right approach

T
TheMrViper, 2015-01-10
@TheMrViper

I just had an idea to write a module for nginx, tell me how crazy it is.
I would also not mind accepting something like php with inserts in c / c ++. It seems convenient and productive, but still not what you need (
You can do this with python, ruby. Then something might work out, but if you already write in c++, then everything at once.

S
Sergey Romanov, 2015-01-11
@Serhioromano

Website - AngularJS
API - PHP/C#/Node - whatever is more convenient.

E
Egor Kazantsev, 2015-01-15
@saintbyte

You do not need an API, but Gearmand

M
Mak1012, 2015-01-15
@Mak1012

I think you've dug too far and are in too much of a hurry.
Start over with a problem statement - what do you want to do?
You will be advised how best to do it.
I suspect that for the first year or two, even one server will be enough for you,
well, the maximum is to place the SQL server on a separate piece of iron.

A
Alexander Dubina, 2015-01-15
@struggleendlessly

Write in C Sharp and don't worry. by the way that I asynchronously and multithreaded did not understand. in most cases, async is more than enough, or will the live video be processed there?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question