Q:

How to overcome the frustration in teaching and doing research at the same time

I understand that this website is designated particularly for teaching-related topics. However as many of us do agree that being a lecturer, we are supposed to run both teaching and research duties at the same time. 
My problem is that I am having quite a heavy teaching load, roughly 40 hours/week. In order to maximize the profit, the university where I am working tries their best to put more pressure on the lecturers, such as they increase the number of students in a classroom but always keep a very basic salary. Doing research and producing publications are also required for lecturers. At the end of each academic year, you need to have at least one paper in some peer-reviewed journals. 
Doing research, learning new knowledge is also my interest. It is a motivation for me to begin a new day. The problem here is that I cannot get focused on only one thing recently. I often try to spend all the night for doing research, however, my mind then continuously keeps thinking to things that I would have for the class tomorrow. Whereas, during the time when I am teaching, I constantly keep thinking on a problem in my research.     
Could you give me some suggestions or recommendations (even small ones) to help me to run both duties more effectively and properly? I really appreciate your help. 
Sorry for my English.

A:

I think there's a lot of variability in publishing rates between different STEM fields and this can lead to administrators imposing unrealistic demands on Mathematics faculty. 
Anecdotally I've heard publishing in Biology once a year is pretty straight-forward: just collect a bunch of new data from a new location and publish the results. Maybe even get a few undergrads to do the dirty work and call it field experience. (My apologies to any bio people if I'm trivializing your work.) Mathematics is different in that procuring new mathematical truths or methods takes a lot of time; working alone and/or with other professionals.
To that end, the MAA Guidelines, Article C.5.1.2, states:

Faculty for whom personnel decisions are based upon assessment of
  contributions in teaching, scholarship, and service should have
  teaching assignments that reflect these multiple expectations and
  allow for attention to non-classroom responsibilities. Teaching
  assignments above three courses [nine credit hours] per semester, when
  combined with other faculty responsibilities, do not allow the time
  needed to develop and maintain a program of sustained scholarship with
  the result that tenure and promotion might be effectively
  unattainable. For such faculty, teaching assignments above the level
  of three courses [nine credit hours] per semester must be avoided.

(It goes on to address faculty at institutions that do require more research and what are acceptable levels of teaching assignments for them.) 
I have found it helpful to communicate to administration that this is what my main professional organization states and that it's not just me making excuses for my lack of research when teaching 12 credits a semester. Hopefully the guidelines can also help you assess your situation and communicate your needs. Good luck.

A:

You state that you just started your teaching job. I would assume that you have a lot of work that needs to be done once, like writing a script or getting familiar with a textbook, designing interesting slides for the lectures, etc. On top of that, you need to get experience as a teacher.
Much of this can be recycled once you give the same class again a few semesters later, so I would strongly suggest to properly store it and already think about how to best use it again.
Furthermore, it might be possible to come to an agreement with your dean/supervisor on that if you are able to show that you want to not do mediocre teaching and mediocre research but set up really good classes now and then do really good research in a few semesters. If that is possible in your special case I don't know of course.
In the long run, teaching and research can be combined by supervising theses. If you don't write a solo paper yourself but instead publish one or two per year together with your Master or PhD students, that should also be accepted.
For now, you have a few options and need to decide for yourself which one to pick (the list is not ordered in any way):

Suck it up and work a lot.
Talk to people and come to an agreement.
Quit.
Do mediocre work and somehow get along.
Be a genius and produce an earth shaking paper in a few days.
Copy others (in teaching, maybe not in writing the paper...).
Analyze your workflow and improve it.
...

