Imagine the following scenario: 50 users are accessing your application simultaneously. They do things there, and some of them are client requests to the server - such requests are asynchronous.
When this happens, multiple parallel and simultaneous requests are sent to your server and it solves how to handle it.
When firing more than one request (asynchronous or not) at a time to the server, the server’s behavior is not necessarily based on a method you employed.
Let’s look at a question of yours:
[...] I would need to use threaded programming on the server?
An asynchronous process is dispersed to threads - not things that should be compared because it has relatively different purposes.
So, to make it clear: you don’t have to do at all nothingness on the server if you do not find it necessary. Your requests are made to the server through a method/verb and depending on the forwarding of an intermediary - controllers, for example -, your application should react in a specific way.
Why threads are different from asynchronous processes?
Threads give an app the ability to work with concurrent processes. A computer can surf the internet and play music simultaneously because of them: they are parallel processes that consume processing - processing that is (re)used to perform multiple tasks.
Your application is one thing only: what it does is its responsibility; if it will enter some information in the database And display a message on the screen: the problem is entirely and exclusively his - which, in turn, is a unique process.
The responsibility of providing the database for the insertion of the information and the browser that is where you will display the message is the responsibility of the operating system. Here, therefore, is where the threads. At first, you nay needs and/or will manage.
But what if I really want to use threads?
You can. Languages offer means and mechanisms for this - C#, by the way, does it very well. What I’m trying to point out is that you not necessarily accurate.
Environments and web languages are naturally equipped to handle parallel processes and you can, most of the time, invest your time focusing only on your requests; in your "AJAX".
As I had imagined. So in a method that does not use Async is not asynchronous? If I make N requests for a non-async method, it will be dealt with in the main thread and will have its return synchronously, correct?
– Vinícius
@Vinícius Exatamente.
– Leonel Sanches da Silva
@Vinícius I would really like to know your need. Is it for study purposes? Is it for scalability purposes? What is the purpose?
– Guilherme Oderdenge
@Guilhermeoderdenge, There is a page in one of the systems I use that makes more than 50 Ajax requests to the server. I suspected that regardless of the amount of requisitions, it was being executed synchronously, as Gypsy clarified. The application is in webforms.
– Vinícius
@Does running synchronously make any difference to you? I ask this because 50 asynchronous requests to the server should not affect applicability. Who knows the performance, but not the applicability - your language and the server will know what to do when simultaneous requests are made. Note: simultaneity is different from competition.
– Guilherme Oderdenge
@Hermeoderdenge, yes. These are pings tests, so I believe they can be done simultaneously without impacting the applicability.
– Vinícius
@Vinicius You want to run the tests simultaneously or you do things in parallel with these tests, such as logging in a log?
– Guilherme Oderdenge
@Guiloderdenge, just test. The method that should be asynchronous just tests and returns whether this ip exists or not. As are many ip’s, everyone’s running time is very large.
– Vinícius
@Vinicius I get it. So go threads! I’ll leave my answer for knowledge purposes.
– Guilherme Oderdenge
great @Guilhermeoderdenge, let me get one last question. If I make N ajax requests simultaneously for a web-service, will it treat each request as a 'client' or will it be queued? Taking into account that you are programming without async.
– Vinícius