D
D
Dmitry Philandor2015-07-07 08:13:22
ASP.NET
Dmitry Philandor, 2015-07-07 08:13:22

How to find out what loads ram and cpu on the asp mvc site?

Hello! There is a news site
with 3 thousand uniques, not so much, what you can only cache - [OutputCache(Duration = 180)]
like this - [OutputCache(Duration = 180, Location = System.Web.UI.OutputCacheLocation.ServerAndClient)] - it doesn't work, you can't write to child elements.
Memory consumption has already exceeded 1 GB. CPU 50% The other day the database began to hang.
I figured out that the database hung when receiving a record when trying to increase the view ( recordDB.Views = Views + tmp;
db.SaveChanges();)

//УВЕЛИЧИМ ПРОСМОТР ЕСЛИ ИСТИНА
    if (db == null) { db = new Times_DLL.Model.TimesDBEntities(); }
  
            if (ViewPlus == true)
            {
                Random rand = new Random();
                var recordDB = (from o in db.Records where o.id == id_record select o).FirstOrDefault();
                int? Views = recordDB.Views ?? 0;

                int tmp = rand.Next(2, 4);               
                recordDB.Views = Views + tmp;
                db.SaveChanges();

                ViewPlus = false;
                var recordDB2 = (from o in db.Records where o.id == id_record select o).FirstOrDefault();
                int? ff = recordDB2.Views ?? 0;
            }


         
            //возвращаем 1 дб объект
            var record = (from rec in db.Records
                           join usr in db.UserProfiles on rec.User_id equals usr.id
                           join typ in db.TypesRecord on rec.Type equals typ.id
                           join cat in db.CategoriesRecord on rec.Category equals cat.id
                           join seo_source in db.SEOs on rec.id equals seo_source.id_record 
                           into t1
                           from seo in t1.DefaultIfEmpty()
                           where rec.id == id_record && rec.Deleted == false
                           select new { record = rec, user = usr, TypeName = typ, PathImgCategory = cat, seo = seo }).AsEnumerable();

            return record.Select(o => MapToRecordsBLLseo(o.record, o.user, o.TypeName, o.PathImgCategory, o.seo)).SingleOrDefault();        
          
        }

commented out completely the increase in viewing - it works and smartly. As a variant it is possible to increase viewing by stored procedure.
I would like advice from specialists and find out how to find out what takes am and cpu in a project

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
andrey57r, 2015-07-07
@andrey57r

Had the same problem and also on the news site. True site in php. We decided to transfer all the counters to redis. Using cron from redis, we periodically record views in the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question