Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+8 votes
942 views
in Q2A Core by
There are 500K questions and 6M answers on my site. My site is running very fast. But It takes too long to save when user ask questions. On average, it takes 40 seconds to record a question. Is there a way to speed up the question save?
Q2A version: 1.8.6
by
How long does it take to...?
 * Close a question
 * Hide a question
 * Hide an answer
 * Vote an answer
 * Select an answer
by
edited by
Saving replies and comments takes less than 1 second. I sped up operations such as question hiding and deletion by making some feature restrictions(in post-update.php). Each takes under 1 second.(Also, I disabled adding words to the "qa_contentwords" table.)

in app/post-create.php;
I moved the functions "qa_db_ccount_update()" and "qa_db_acount_update()" into qa_question_create(). I disabled some methods. Thus, saving answers and saving comments has become very fast.
You can look at lines 261, 124 in the link I shared.
I couldn't optimize the question recording. I guess it takes a long time to do some calculations.
https://github.com/kksal55/shared/blob/main/post-create.php

Can we add the following functions(in post-create.php) as a cron process that runs periodically, not when every question, answer or comment is recorded?
When I remove these functions, the question recording function takes ~5 seconds.

qa_db_qcount_update();
qa_db_unaqcount_update();
qa_db_unselqcount_update();
qa_db_unupaqcount_update();
qa_db_tagcount_update();
qa_db_acount_update();
qa_db_ccount_update();
by
I have the same problem, please how did you solve the problem?

1 Answer

+3 votes
by
selected by
 
Best answer

Try applying these changes: https://github.com/q2a/question2answer/pull/910

If you want to apply additional performance improvements at the expense of not being able to search for posts (like not updating the qa_words table), that will boost performance more.

But please, DO let me know the times things take BEFORE these changes and AFTER these changes. To properly test it, do this:

  1. Backup your current file (the one with those changes)
  2. Replace it with the official standard file
  3. Run the tests I mentioned in the comment above and take a note (you can measure using the web browser inspector, in the networking tab you'll see the requests)
  4. Apply the changes from my pull request
  5. Execute step 3 again
  6. Share the results here
Obviously, if you then want to apply more changes, go ahead. The thing is that these changes won't sacrifice any feature, while more "aggressive" changes, will.
by
+1
I will make all the changes as soon as possible and provide you with a report. Thanks for your help.
by
That is a great work, i will update my site to this version.
And i think my question can also closed
 
https://www.question2answer.org/qa/101424/have-posts-post-quesion-when-hide-delete-posts-cost-much-time
by
edited by
Time decreased in ~85% compared to current Q2A version for add question. The measured seconds values are average values for the live user.

The test site had this structure:

Questions: 470.000
Answers: 2.700.000
Comments: 3.600.000

Current Q2A version(modified by me)
Add a question: ~40 sec <=====
Edit a question: 6 sec
Closing a question: 1
Hiding a question: 1 sec
Reshowing a question: 1 sec
Hiding a answer: 1 sec
Reshowing a answer: 1 sec
Give vote on answer: 4 sec
Select answer: 5 sec
Deselect answer: 5 sec

Current Q2A version(modified by pupi1985)
Add a question: ~5 sec  <=====
Edit a question: 4 sec
Closing a question: 0,5 sec
Hiding a question: 1 sec
Reshowing a question: 1 sec
Hiding a answer: 0,5 sec
Reshowing a answer: 0,5 sec
Give vote on answer: 2,5 sec
Select answer: 2 sec
Deselect answer: 1,5 sec

The latest versions of the files I changed are in this link
https://github.com/kksal55/shared

Thank you for your help @pupi1985
by
+1
This is very useful. You haven't provided the original Q2A measurements, but rather the ones after your changes, which have already increased speed at the cost of features and keeping numbers up-to-date.

Anyway, the performance increase between your changes and mine, is pretty clear. The good thing is that you don't lose any feature with my changes. There are probably more things to do in order to increase performance in the future. I might find some time in the next months to work on that
by
Please, I want to apply changes to my website. I do not have the experience to do this. Can you help me in exchange for purchasing the service?
...