The legal standard is whether the parties trying to personally serve someone with process have exercised reasonable diligence in attempting to do so. California Rule of Court 5.72 controls. It states in the pertinent part:
If the respondent cannot be found to be served a summons by any method described in Code of Civil Procedure sections 415.10 through
415.40, the petitioner may request an order for service of the summons by publication or posting under Code of Civil Procedure sections
415.50 and 413.30, respectively.
(a) Service of summons by publication or posting; forms
To request service of summons by publication or posting, the
petitioner must complete and submit to the court Application for Order
for Publication or Posting (form FL-980) and Order for Publication or
Posting (form FL-982). Alternatively, petitioner may complete and
submit to the court pleadings containing the same information as forms
FL-980 and FL-982. The petitioner must list all the reasonable
diligent efforts that have been made to find and serve the
respondent.
This is a case by case analysis. The number of attempts made to serve process is not the only issue.
Assume they know (or should know) where the person lives.
How many attempts should be made depends upon how difficult it should be to personally serve the defendant with process and whether or not it appears that further attempts to serve the defendant with process would be futile.
The most common case where service by publication is allowed in cases where the defendant can't be served because the defendant cannot be found. Arguably, it is the only reason that service by publication can be allowed.
To show reasonable diligence in trying to determine where the person is, at a minimum, one probably needs to order a professional skip trace search of the person one is trying to find, and in this modern day, one should make an attempt to Google them.
Also, one should investigate whether the person can be found at any last known address that is available to the person trying to serve them with process. Even if one determines that they don't live there anymore, there may be a mail forwarding order in place, or the person who lives there now may know how to contact the person who used to live there. The current resident might also know, for example, that the person is now deceased, or in prison, or has been moved to a nursing home or hospital, or has been deported, which would be relevant to a motion to serve process by publication.
If the plaintiff knows where the defendant is located, and simply can't manage to get pleadings into the defendant's hands, it is far more common for the court to order the plaintiff to "try harder" once or twice until the court is satisfied that adequate efforts have been made, or to order "substituted service" allowing, for example, service of process by mail, or by email, or upon a doorman in a limited access building, or otherwise addressing the issues that made personal service of process difficult. See generally CCP ยง 415.20.
Also, if you serve by publication, and the person to be served doesn't have actual notice, and default judgment is entered, then, after the person to be served gains actual knowledge that person files something in the case within a reasonable time of gaining actual knowledge, the default judgment must be set aside as a matter of U.S. constitutional law. The leading case on that issue is Mullane v. Central Hanover Bank, 339 U.S. 306 (1950).