mariadb slow to response due to high query i have a g7 server that use as database server
and i installed window server 2016 and maria db version 10.1.39-MariaDB on it  

my hardware have 2 CPU  Intel(R) Xeon(R) CPU E5620 @ 2.40GHz and 64 gig of ram and 4*128 gig hp ssd 6gbps raid 10

but when my load is going up to 1000 query per second it slow down and crashed..
all my tables are innodb and i have 500-600 mil record and db size is about 40-50 gig

my config is 

[mysqld]
port        = 3306
socket      = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 512M
innodb_file_per_table=1
max_connection=4000

table_open_cache = 1536
sort_buffer_size = 2M
read_buffer_size = 256K
read_rnd_buffer_size = 256k
myisam_sort_buffer_size = 64M
thread_cache_size = 256
query_cache_size = 64M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 12

max_allowed_packet=16M

innodb_io_capacity = 2000
innodb_read_io_threads = 64
innodb_thread_concurrency = 0
innodb_write_io_threads = 64

#innodb_dedicated_server = true

innodb_buffer_pool_size = 48G
innodb_buffer_pool_instances = 24


which of my config is wrong and how can i get the best performance!?

update:when database stoped ram usage is 4-5 gig and when database in load ram go up to 40-45 gig,also my used my connection is about 3500 connection..
3500 -- is that Max_used_connections? If so, that is terrible. Imagine 3500 people, each with a grocery cart, in a grocery store. Imagine them trying to move through the aisles to pick up food items. It is a mess; essentially it is too crowded for anyone to get anything done. The same thing happens with MySQL/MariaDB.  In this case it is mutexes, and other things.

Put another way, each process gets 2/3500 of the CPU time.  That is, practically none.  So, each connection takes really long to get anything finished.

So, the cure is to find the slow queries and speed them up.  See:  http://mysql.rjweb.org/doc.php/mysql_analysis#slow_queries_and_slowlog

(Use long_query_time=1 so you can catch some of the shorter, but frequent, queries.)