πŸ›οΈ HONGIKINGAN CMS Developer Manual

Version 202506 | Updated 2025-06-12
🌐 Language: πŸ‡°πŸ‡· ν•œκ΅­μ–΄ πŸ‡²πŸ‡³ Монгол πŸ‡ΊπŸ‡Έ English

8. ⚑ Performance Optimization

8.1 Cache System

HONGIKINGAN CMS provides an EhCache-based cache system for performance improvement. It minimizes database access and improves response time by caching frequently used data in memory.

8.1.1 Cache Configuration

HONGIKINGAN CMS provides the following caches:

πŸ—„οΈProvided Cache Types

  • humanCommonCache: Caching common data such as site menus
  • humanCodeCache: Caching code data

🌐Distributed Cache Network Port Verification

HONGIKINGAN CMS's EhCache uses the following network ports for cache synchronization in multi-server environments:

  • Multicast Address: 230.0.0.1
  • Peer Multicast Port: 4446
  • Message Receiving Port: 40001

Important: If cache synchronization errors occur in a multi-server environment, it is necessary to check whether these ports are being used by other applications. Port conflicts may prevent cache clustering from functioning properly.

Port Usage Verification Methods
# Check port usage in Linux/Unix environment
netstat -an | grep 4446
netstat -an | grep 40001

# Check port usage in Windows environment
netstat -an | findstr 4446
netstat -an | findstr 40001
ehcache-human.xml Configuration
<?xml version="1.0" encoding="UTF-8"?>
<ehcache updateCheck="false">
    <diskStore path="user.dir/second"/>
    <defaultCache maxEntriesLocalHeap="100"
                  eternal="false"
                  overflowToDisk="false"
                  />

    <cache name="humanCommonCache"
           maxEntriesLocalHeap="5000"
           eternal="false"
           overflowToDisk="false"
           timeToLiveSeconds="300"
           memoryStoreEvictionPolicy="LRU">
           <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" />
    </cache>

    <cache name="humanCodeCache"
           maxEntriesLocalHeap="1000"
           eternal="false"
           overflowToDisk="false"
           timeToLiveSeconds="7200"
           memoryStoreEvictionPolicy="LRU">
    </cache>
</ehcache>

8.1.2 Cache Service

HONGIKINGAN CMS provides HumanEhcacheService for cache management.

Main Features

Implementation Class
@Service("humanEhcacheService")
public class HumanEhcacheServiceImpl extends HumanAbstractServiceImpl implements HumanEhcacheService {

    @Resource(name="comm.ehcache.humanCommonCache")
    Ehcache humanCommonCache;

    @Resource(name="comm.ehcache.humanCodeCache")
    Ehcache humanCodeCache;

    @Override
    public void removeCache(String targetCache, String cacheCode) throws Exception {
        if(EgovStringUtil.equals("code", targetCache)){
            if (humanCodeCache.isKeyInCache(cacheCode)) {
                humanCodeCache.remove(cacheCode);
            }
        } else if(EgovStringUtil.equals("common", targetCache)){
            if (humanCommonCache.isKeyInCache(cacheCode)) {
                humanCommonCache.remove(cacheCode);
            }
        }
    }

    @Override
    public void removeAllCaches(String targetCache) throws Exception {
        List cacheKeyList = null;

        if(EgovStringUtil.equals("code", targetCache)){
            cacheKeyList = humanCodeCache.getKeys();
            for (int i=0; i<cacheKeyList.size(); i++) {
                String cacheKey = (String) cacheKeyList.get(i);
                if (humanCodeCache.isKeyInCache(cacheKey)) {
                    humanCodeCache.remove(cacheKey);
                }
            }
        } else if(EgovStringUtil.equals("common", targetCache)){
            cacheKeyList = humanCommonCache.getKeys();
            for (int i=0; i<cacheKeyList.size(); i++) {
                String cacheKey = (String) cacheKeyList.get(i);
                if (humanCommonCache.isKeyInCache(cacheKey)) {
                    humanCommonCache.remove(cacheKey);
                }
            }
        }
    }
}

8.1.3 Cache Usage Examples

Various services in HONGIKINGAN CMS utilize cache to optimize performance.

Code Service
@Service("codeService")
public class CodeServiceImpl extends EgovAbstractServiceImpl implements CodeService {

    @Resource(name = "comm.ehcache.humanCodeCache")
    Ehcache humanCodeCache;

    @Resource(name = "humanEhcacheService")
    HumanEhcacheService ehcacheService;

    public List<CodeVO> retrieveCodeList(Map paramMap) throws Exception {
        String cacheNm = "codeCache_" + /* Cache key generation logic */;
        
        Element el = humanCodeCache.get(cacheNm);

        if (el == null) {
            List<CodeVO> codeList = codeDAO.retrieveCodeList(paramMap);
            humanCodeCache.put(new Element(cacheNm, codeList));
            el = humanCodeCache.get(cacheNm);
        }

        return (List<CodeVO>) el.getValue();
    }

    public void updateCode(CodeVO codeVO) throws Exception {
        codeDAO.updateCode(codeVO);
        // Remove cache when code changes
        ehcacheService.removeAllCaches("code");
    }
}
Site Service
@Service("siteService")
public class SiteServiceImpl extends EgovAbstractServiceImpl implements SiteService {

    @Resource(name="comm.ehcache.humanCommonCache")
    Ehcache humanCommonCache;

    @Resource(name = "humanEhcacheService")
    HumanEhcacheService ehcacheService;

    public List selectSiteMenuListAll() throws Exception {
        Element el = humanCommonCache.get("siteListCache");

        if (el == null) {
            List<SiteVO> siteMenuList = siteDAO.selectSiteMenuListAll();
            humanCommonCache.put(new Element("siteListCache", siteMenuList));
            el = humanCommonCache.get("siteListCache");
        }
        return (List<SiteVO>) el.getValue();
    }

    public void updateSite(SiteVO siteVO, String pblcateYN) throws Exception {
        // Remove cache when site information changes
        ehcacheService.removeAllCaches("common");
        
        // Update site information
        siteDAO.updateSite(siteVO);
    }
}

8.2 Database Query Optimization

HONGIKINGAN CMS uses MyBatis to manage database queries. Database performance can be optimized through efficient query writing.

8.2.1 Index Utilization

Query performance can be improved by creating appropriate indexes.

πŸ’‘

Index Utilization Tips

  • Create indexes on frequently searched columns
  • Prioritize columns used in WHERE clauses
  • Improve performance by utilizing composite indexes
  • Unnecessary indexes can be a performance degradation factor

8.2.2 Pagination Processing

Implement pagination processing to efficiently handle large amounts of data.

πŸ“„

Pagination Processing Benefits

  • Memory usage optimization
  • Reduced response time
  • Improved user experience
  • Server load distribution

8.3 Conclusion

HONGIKINGAN CMS optimizes performance through an EhCache-based cache system. It minimizes database access and improves response time by caching frequently used data in memory. Additionally, the overall system performance can be improved through efficient database query writing.

🎯

Performance Optimization Key Points

  • Cache Utilization: Reduce database load through memory caching with EhCache
  • Query Optimization: Efficient SQL writing and index utilization
  • Pagination Processing: Efficient processing of large amounts of data
  • Continuous Monitoring: Continuous improvement through performance metrics monitoring